Question : Why isn't this working

I recieve this message when I run it,"Msg 4145, Level 15, State 1, Line 16
An expression of non-boolean type specified in a context where a condition is expected, near 'AND'."

It has to do with this join,"LEFT JOIN PatientInsurance pip ON pip.PatientProfileId = pp.PatientProfileId AND ISNULL(pip.Inactive,0)  AND pip.OrderForClaims = '1'"

Any suggestions
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
SET NOCOUNT ON
SELECT DISTINCT
pp.First,
pp.Last,
pp.Birthdate,
pp.Sex,
pp.MedicalRecordNumber,
pp.Address1,
pp.City,
pp.State,
pp.Zip,
ic.ListName
 
 
FROM PatientProfile pp
LEFT JOIN PatientInsurance pip ON pip.PatientProfileId = pp.PatientProfileId AND ISNULL(pip.Inactive,0)  AND pip.OrderForClaims = '1'
LEFT JOIN InsuranceCarriers ic ON ic.InsuranceCarriersId = pip.InsuranceCarriersId
 
Order by pp.Last
Open in New Window Select All

Answer : Why isn't this working

missing a value in your JOIN statement...changed it to:
ISNULL(pip.Inactive,0) = 1 AND


SET NOCOUNT ON
SELECT DISTINCT
pp.First,
pp.Last,
pp.Birthdate,
pp.Sex,
pp.MedicalRecordNumber,
pp.Address1,
pp.City,
pp.State,
pp.Zip,
ic.ListName
 
 
FROM PatientProfile pp
LEFT JOIN PatientInsurance pip ON pip.PatientProfileId = pp.PatientProfileId AND ISNULL(pip.Inactive,0) = 1 AND pip.OrderForClaims = '1'
LEFT JOIN InsuranceCarriers ic ON ic.InsuranceCarriersId = pip.InsuranceCarriersId
 
Order by pp.Last

Random Solutions  
 
programming4us programming4us