I'm having trouble with the following select statment select patient_id , sum(case when ch.cancer_site_id in ('3', '39', '12') and min(ch.diagnosis_age) < 40 then '1' else '0' end) as Breast from ... group by patient_id I'm getting a "not a single-group group function" error. I'm not sure if it's just a syntax error or if this function isn't supported in oracle. If it's not allowed, what I'm trying to find out is if the earliest age a patient was diagnosed with breast cancer is less than 40 years old. The 3 different cancer site id's are the different types of breast cancer that get grouped together. If you have a better way to do this then let me know.