My question is how to separate different values of a column into several columns and give a count on each item according to the name in postgres, follow the example below
How are you?
--TIPO O.S.--Count----Nome
1009 || 1 || Lucas
1008 || 2 || Lucas
1008 || 2 || Juliana
1007 || 2 || Juliana
1007 || 2 || Lucas
1008 || 2 || Vanessa
1007 || 3 || Vanessa
SQL: select os.tipo_os,count(os.tipo_os), pe.nome_usuario
from table_os as os, table_pessoas as pe
where os.codigo_usuario = pe.codpessoa
group by os.tipo_os, pe.nome_usuario
How to Stay:
--1009----1008----1007----Nome
1 || 2 || 2 || Lucas
|| 2 || 2 || Juliana
|| 2 || 3 || Vanessa