2012/8/29 Edson Lidorio <edson...@gmail.com>

> Só ordena, no ano atual
> veja como aparece:
>
> 3/2012
> 4/2010
> 4/2012
> 5/2012
> 6/2011
> 6/2012
> 7/2012
> 8/2012
>
>
>
Eu faria o seguinte:


SELECT to_char(a.dt_mov, 'MM/YYYY') AS mes, sum(a.vlr_final) AS total
FROM movdirhe a
WHERE a.dt_mov between '01/01/2010' and '21/08/2012'
GROUP BY to_char(a.dt_mov, 'MM/YYYY'), to_char(a.dt_mov, 'YYYY-MM')
ORDER BY to_char(a.dt_mov, 'YYYY-MM');


Atenciosamente,
--
Matheus de Oliveira
_______________________________________________
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a