0
I have a table like this:
++++++++++++++++++++++++++++++++++++++++
+ Nome | Cargo | Estado +
+ ++++++++++++++++++++++++++++++++++++++
+ Joao | Estagiário | RJ +
+ Maria | Analista | RJ +
+ Thiago| Gerente | SP +
+ Pedro | Analista | SP +
+ Joana | Estagiário | MG +
++++++++++++++++++++++++++++++++++++++++
And I would like to select in SQL to get a result like this:
+++++++++++++++++++++++++++++++++++++++++++++++++
+ Estado| Estagiário | Analista | Gerente +
+ +++++++++++++++++++++++++++++++++++++++++++++++
+ MG | 2 | 3 | 1 +
+ RJ | 1 | 2 | 1 +
+ SP | 1 | 2 | 3 +
+++++++++++++++++++++++++++++++++++++++++++++++++
I used the following query:
select count distinct Cargo
from tabela1
where Cargo in ('Analista')
group by Estado
But it didn’t work out so well.