If we wanted to get all the ages for patients have a Cholesterol lab, we could run the following query:
SELECT CONCEPT_CD
FROM OBSERVATION_FACT
WHERE CONCEPT_CD LIKE 'DEM|Age%'
AND PATIENT_NUM IN
(SELECT PATIENT_NUM
FROM OBSERVATION_FACT
WHERE CONCEPT_CD IN
(SELECT CONCEPT_CD
FROM CONCEPT_DIMENSION
WHERE CONCEPT_PATH LIKE '%LAB(LLB16) Chemistry(LLB17) Lipid Tests\CHOL%'
)
)
Notice how the path of the concept is used to query all concept ids that fall into the cholesterol group. If we only wanted to query for patient with Plasma Cholesterol only we would use the same query with the following path joined against C_FULLNAME:
'%LAB(LLB16) Chemistry(LLB17) Lipid Tests\CHOL\MCSQ-PCHOL%'
OR
'%LAB(LLB16) Chemistry(LLB17) Lipid Tests\CHOL\MCPCHOL%'