Hello, I need a way to do an sql query that will bring me the amount of male and female people. NOTE: I have two tables where the first one is registered in it I have the sex column and another table that would be entered only with the addressname. The register table has a column named fok_faixaetaria which is a foreign key for the column array. I would like to conduct a consultation that would bring a lot of people, male and female, by area.
SELECT COUNT(case when sexo= 'Masculino' then 1 end) AS Masculino,
COUNT(case when sexo= 'Feminino' then 1 end) AS Feminino FROM cadastro
where dataInicial = '01/08/2015' and dataFinal = '31/08/2015'
How can I make the query being that I have 6 age range and would like to count each male and female by age group?