HI
I am baffled and have tries all ways to count Distinct information.
My database records learners and enrolments, and I need to count the unique number of learners for different categories, such as gender and Disability but SQL results are counting the number of enrolments.
In this SQL the Learner count is correct but the Disability total add up to the amount of enrolments.
SELECT
count(distinct p.PERSON_CODE) Learners
,count(Case when p.Primary_Disability=91 then 1 End) 'With_Disability'
,count(Case when p.Primary_Disability=98 then 1 End) 'No_Disability'
,count(Case when p.Primary_Disability is Null then 1 End) 'Blank'
From ****
I am baffled and have tries all ways to count Distinct information.
My database records learners and enrolments, and I need to count the unique number of learners for different categories, such as gender and Disability but SQL results are counting the number of enrolments.
In this SQL the Learner count is correct but the Disability total add up to the amount of enrolments.
SELECT
count(distinct p.PERSON_CODE) Learners
,count(Case when p.Primary_Disability=91 then 1 End) 'With_Disability'
,count(Case when p.Primary_Disability=98 then 1 End) 'No_Disability'
,count(Case when p.Primary_Disability is Null then 1 End) 'Blank'
From ****