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 do a 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've used the following query:
select count distinct Cargo
from tabela1
where Cargo in ('Analista')
group by Estado
But it did not work very well.