I have this query:
SELECT count(*) as total, * FROM ( select case when pd_edad <=0 then '01'
when pd_edad >=65 then '15'
END as age_range,pd_sexo,pd_diagnostico from paciente
where PD_CFEC between '2017/01/12' and '2017/31/12') t
group by PD_SEXO,age_range,pd_diagnostico
order by PD_SEXO desc,age_range asc, pd_diagnostico asc
Take for example, a model here to build the query,
I need to count unique values of the DNI field found in this table, but I only want to see only these fields by age range , I hope your help, thanks.