NickMalloy
asked on
Error around If Clause
I have a query that is throwing a comma error around my if clause. What am I missing??
SELECT p.ID as PatientID,
p.MedicalNumber as MRN,
p.LastName,
p.FirstName,
p.Status,
p.Age,
p.Sex as Gender,
p.AdmitDate,
p.DischargeDate,
p.AdmittingDiagnosis as Diagnosis,
loc.Abbreviation as CurrentLocation,
loc.PatientUnit as CurrentUnit
FROM Patient p
LEFT JOIN Location loc on loc.ID= Iif(p.HomeLocation is null,p.Destination,p.HomeL ocation)
ORDER BY p.LastName,p.FirstName
SELECT p.ID as PatientID,
p.MedicalNumber as MRN,
p.LastName,
p.FirstName,
p.Status,
p.Age,
p.Sex as Gender,
p.AdmitDate,
p.DischargeDate,
p.AdmittingDiagnosis as Diagnosis,
loc.Abbreviation as CurrentLocation,
loc.PatientUnit as CurrentUnit
FROM Patient p
LEFT JOIN Location loc on loc.ID= Iif(p.HomeLocation is null,p.Destination,p.HomeL
ORDER BY p.LastName,p.FirstName
LEFT JOIN Location loc on loc.ID= Iif(p.HomeLocation is null,p.Destination,p.HomeL ocation)
Is it supposed to be Iif or If, or is this a typo???
-saige-
Is it supposed to be Iif or If, or is this a typo???
-saige-
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT p.ID as PatientID,
p.MedicalNumber as MRN,
p.LastName,
p.FirstName,
p.Status,
p.Age,
p.Sex as Gender,
p.AdmitDate,
p.DischargeDate,
p.AdmittingDiagnosis as Diagnosis,
loc.Abbreviation as CurrentLocation,
loc.PatientUnit as CurrentUnit
FROM Patient p
LEFT JOIN Location loc
on loc.ID= coalesce(p.homelocation,p. Destinatio n)
ORDER BY p.LastName,p.FirstName
p.MedicalNumber as MRN,
p.LastName,
p.FirstName,
p.Status,
p.Age,
p.Sex as Gender,
p.AdmitDate,
p.DischargeDate,
p.AdmittingDiagnosis as Diagnosis,
loc.Abbreviation as CurrentLocation,
loc.PatientUnit as CurrentUnit
FROM Patient p
LEFT JOIN Location loc
on loc.ID= coalesce(p.homelocation,p.
ORDER BY p.LastName,p.FirstName
case when ... then ... else ... end