0
I’m trying to group a table so I can make a Count, but I’m having difficulties.
The structure of the table is as follows:
ID - NOME - IDADE - ESCOLARIDADE
1 - João - 15 - Ensino Fundamental Completo
2 - José - 25 - Ensino Fundamental Completo
3 - Mara - 13 - Ensino Fundamental Completo
4 - Joca - 50 - Ensino Fundamental Incompleto
I need to group and count as follows, count how many people between the age of 12 and 65 have completed elementary school, how many have incomplete. The result of the query in the table shown would be:
0-12 - Ensino Fundamental Completo - TOTAL: 0
12-65 - Ensino Fundamental Completo - TOTAL: 3
0-12 - Ensino Fundamental Incompleto - TOTAL: 0
12-65 - Ensino Fundamental Incompleto - TOTAL: 1
I have tried several ways and nothing has worked. Can anyone help me? Ah, schooling is in another table, it has a foreign key too, but not putting it in select. I am using Postgresql