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.BIRTH_DATE <=DATEADD(year,-18,CURRENT_TIMESTAMP )
THEN 'Adult'
WHEN pats.BIRTH_DATE <=DATEADD(year,-1,CURRENT_TIMESTAMP )
THEN 'Child"
WHEN pats.BIRTH_DATE IS NOT NULL
THEN 'Infant' ELSE 'Missing Birthdate"
END PATIENT_AGE_GROUP
FROM
PATIENT pats
However, when you try to join to this subquery, shown below, you get an error.
SELECT
PAT_NAME
,PATIENT_AGE_GROUP
FROM PATIENT pat
INNER JOIN (/*subquery */)pat_age ON pat.PAT_ID =pat_age.PAT_ID
What is causing the error?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!