I'm trying to group a table so I can count, but I'm having trouble.
The table structure 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 ages 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 many ways and nothing has worked. can anybody help me? Ah, schooling is on another table, it has a foreign key too, but not to putting on the select. I'm using PostgreSQL