This is probably simple, but I am not seeing it. I am getting an error message Incorrect syntax near the keyword 'if'
for the following SQL.
The DF.IsBillingEntity
is a bit column.
select OBS_CC.OBSVALUE 'Cost Center'
,U.LASTNAME 'Staff Lastname'
,U.FIRSTNAME 'Staff Firstname'
,U.LOGINNAME 'Staff Login'
,if (DF.IsBillingEntity = 1)
select 'Billable';
else
select 'Not Billable';
,DF.Suffix 'Credentials'
,OBS_SUP.OBSVALUE 'Supervisor'
,D.SUMMARY 'Note Name'
,D.DB_CREATE_DATE 'Date Created'
,dbo.Convert_ID_to_date(D.PUBTIME) 'Note Signed'
from DOCUMENT D
left join OBS OBS_CC on OBS_CC.SDID = D.SDID and OBS_CC.HDID=75246
left join PatientProfile P on D.SDID = P.SSDID
left join OBS OBS_SUP on OBS_SUP.SDID=D.SDID and OBS_SUP.HDID=711437
inner join USR U on D.USRID=U.PVID
left join DoctorFacility DF on U.PVID=DF.PVId
where OBS_SUP.OBSVALUE is not null
and dbo.cusExcludeRecords(P.PID,U.PVId) = -1
order by 1,2,3,6
1