Well I have a database that contains professions, people, and sex
I wanted to group by age group and by profession and sex and make a calculation of them.
problem repeats several bands for example the profession has four lines of F sex, with the same profession and different count values for the same age range.
SELECT SEXO.SEXO,
PROFISSAO.PROFISSAO,
COUNT (CASE WHEN DADOS.IDADE BETWEEN "0" AND "20" THEN "ate 20" END)
AS FAIXAETARIA20,
COUNT (
CASE WHEN DADOS.IDADE BETWEEN "21" AND "50" THEN "de 21 a 50" END
)
AS FAIXAETARIA2250,
COUNT (
CASE WHEN DADOS.IDADE BETWEEN "51" AND "75" THEN "de 51 a 75" END
)
AS FAIXAETARIA51200
FROM DADOS
LEFT JOIN
SEXO
ON (DADOS.SEXO = SEXO.ID)
LEFT JOIN
PROFISSAO
ON (DADOS.PROFISSAO = PROFISSAO.ID)
GROUP BY PROFISSAO.PROFISSAO, SEXO.SEXO, DADOS.IDADE