Question: You write the following subquery to define custom age groups for your patients: SELECT CASE WHEN pats.BIRTH _ DATE < = DATEADD ( year ,
You write the following subquery to define custom age groups for your patients:
SELECT
CASE
WHEN pats.BIRTHDATE DATEADDyearCURRENTTIMESTAMP
THEN 'Adult'
WHEN pats.BIRTHDATE DATEADDyearCURRENTTIMESTAMP
THEN 'Child"
WHEN pats.BIRTHDATE IS NOT NULL
THEN 'Infant' ELSE 'Missing Birthdate"
END PATIENTAGEGROUP
FROM
PATIENT pats
However, when you try to join to this subquery, shown below, you get an error.
SELECT
PATNAME
PATIENTAGEGROUP
FROM PATIENT pat
INNER JOIN subquery patage ON pat.PATID patage.PATID
What is causing the error?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
