Hi,I have this working fineSELECT A.CapId, ISNULL((SELECT F.CH FROM dbPubMatrix..tblNewMatrixFigures F WHERE F.VehicleRef = A.VehicleRef and F.maintained=0 and F.MilesPA=10000 and F.Term =3),0) as Price_3FROM dbPubMatrix..tblNewMatrixArval A WHERE A.CapId IN (47106,47104,47105,47099,47097,47098,47101,47103,47100,47102)
I need to add other columns with different MilesPA, so I tried thisSELECT A.CapId, ISNULL((SELECT F.CH FROM dbPubMatrix..tblNewMatrixFigures F WHERE F.VehicleRef = A.VehicleRef and F.maintained=0 and F.MilesPA=10000 and F.Term =3),0) as Price_3FROM dbPubMatrix..tblNewMatrixArval A WHERE A.CapId IN (47106,47104,47105,47099,47097,47098,47101,47103,47100,47102),ISNULL((SELECT F.CH FROM dbPubMatrix..tblNewMatrixFigures F WHERE F.VehicleRef = A.VehicleRef and F.maintained=0 and F.MilesPA=20000 and F.Term =3),0) as Price_3FROM dbPubMatrix..tblNewMatrixArval A WHERE A.CapId IN (47106,47104,47105,47099,47097,47098,47101,47103,47100,47102)
But that has an error, any help appreciated. Thanks.