>>Tenho a seguinte tabela e gostaria que a mesma gera-se as informações igual a 
>>consulta abaixo. É possível gerar uma consulta com o resultado abaixo?


Veja se este artigo te ajuda

http://www.vertabelo.com/blog/technical-articles/creating-pivot-tables-in-postgresql-using-the-crosstab-function

[http://vertabelo.com/_fileserver/item/1503758/report.jpg?timestamp=1463650608322]<http://www.vertabelo.com/blog/technical-articles/creating-pivot-tables-in-postgresql-using-the-crosstab-function>

Pivot Tables in PostgreSQL Using the Crosstab 
Function<http://www.vertabelo.com/blog/technical-articles/creating-pivot-tables-in-postgresql-using-the-crosstab-function>
www.vertabelo.com
Pivot Tables in PostgreSQL Using the Crosstab Function. by Maria Alcaraz 
Database Developer. Posted: May 19, 2016



At.te,
Saulo Morais


________________________________
De: pgbr-geral <pgbr-geral-boun...@listas.postgresql.org.br> em nome de Thiago 
H. Barreto <thi...@sedcontabilidade.com.br>
Enviado: quinta-feira, 13 de julho de 2017 11:33:11
Para: Comunidade PostgreSQL Brasileira
Assunto: [pgbr-geral] Ajuda consulta

Bom dia a todos.

Tenho a seguinte tabela e gostaria que a mesma gera-se as informações igual a 
consulta abaixo. É possível gerar uma consulta com o resultado abaixo?

Tabela 01
ID      Nome    Data    Base    Imposto







1       Carla   01/01/2017      3.000,00        240,00







1       Carla   01/02/2017      3.100,00        248,00







1       Carla   01/03/2017      3.000,00        240,00







1       Carla   01/04/2017      3.200,00        256,00







1       Carla   01/05/2017      3.000,00        240,00







2       Matheus 01/01/2017      1.500,00        120,00







2       Matheus 01/02/2017      1.700,00        136,00







2       Matheus 01/03/2017      1.500,00        120,00







3       Igor    01/01/2017      4.500,00        360,00







3       Igor    01/02/2017      2.000,00        160,00







3       Igor    01/03/2017      4.500,00        360,00







3       Igor    01/04/2017      3.580,00        286,40







3       Igor    01/05/2017      4.500,00        360,00





















        Resultado       Consulta










        Apos a consulta












        01/01/2017      01/02/2017      01/03/2017      01/04/2017      
01/05/2017      01/01/2017      01/02/2017      01/03/2017      01/04/2017      
01/05/2017
1       Carla   3.000,00        3.100,00        3.000,00        3.200,00        
3.000,00        240     248     240     256     240
2       Matheus 1.500,00        1.700,00        1.500,00        120     136     
120




3       Igor    4.500,00        2.000,00        4.500,00        3.580,00        
4.500,00        360     160     360     286,4   360



Obrigado.


--
Thiago H. Barreto
Sed Contabilidade S/S Ltda
thi...@sedcontabilidade.com.br<mailto:thi...@sedcontabilidade.com.br>







Lembre-se de que ao evitar o desperdício, além de economizar dinheiro com papel 
e tinta, você também ajuda o nosso planeta. Bom para seu bolso, melhor para o 
mundo!
_______________________________________________
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a