Thanks Dapi, (new icon looks slightly menacing, gulp!)
Your code outputs as follows....
I need to remove the DAY format, as this will only confuse the client.Code:select TRUNC(posting_date,'MON'), sum(amount) from w_card_transaction ct where posting_date > to_date('31-12-2003','DD-MM-YYYY') and posting_date < to_date('01-01-2005','DD-MM-YYYY') group by TRUNC(posting_date,'MON') order by TRUNC(posting_date,'MON'); TRUNC(POSTING_DATE,' SUM(AMOUNT) -------------------- ----------- 01-Jan-2004 00:00:00 73421822 01-Feb-2004 00:00:00 65580379 01-Mar-2004 00:00:00 73544607 01-Apr-2004 00:00:00 68714657 01-May-2004 00:00:00 69430156 01-Jun-2004 00:00:00 71043087 01-Jul-2004 00:00:00 73624546 01-Aug-2004 00:00:00 80102705 01-Sep-2004 00:00:00 84481250 01-Oct-2004 00:00:00 93033185 01-Nov-2004 00:00:00 110017083 01-Dec-2004 00:00:00 100254770
So far I've got...
But the order by clause on a 'to_char' is screwing me up now....Code:select to_char(posting_date,'Mon-YYYY'), sum(amount) from w_card_transaction where posting_date > to_date('31-12-2003','DD-MM-YYYY') and posting_date < to_date('01-01-2005','DD-MM-YYYY') group by to_char(posting_date,'Mon-YYYY') order by to_char(posting_date,'Mon-YYYY'); TO_CHAR( SUM(AMOUNT) -------- ----------- Apr-2004 68714657 Aug-2004 80102705 Dec-2004 100254770 Feb-2004 65580379 Jan-2004 73421822 Jul-2004 73624546 Jun-2004 71043087 Mar-2004 73544607 May-2004 69430156 Nov-2004 110017083 Oct-2004 93033185 Sep-2004 84481250
Unless you have a more elegant solution?




Reply With Quote