Re: SQL Query Question - HELP!

From: Tony <andrewst_at_onetel.net.uk>
Date: 27 Mar 2003 02:51:54 -0800
Message-ID: <c0e3f26e.0303270251.3db81840_at_posting.google.com>


d_dood_at_hotmail.com (MAL) wrote in message news:<68fa75f2.0303261502.19f64fcf_at_posting.google.com>...
> I am trying to figure out how to take the date info and just turn it
> into a month and count the number of requests per month.

The TRUNC function can be used to get the month for a given date:

TRUNC(datecol,'MM')

It actually returns a full date: the 1st of the month, at 00:00:00

You can then format this using TO_CHAR, so that the query becomes:

SELECT TO_CHAR( TRUNC(datecol,'MM'), 'FMMonth YYYY' ) , SUM( totalcol )
FROM mytable
GROUP BY TRUNC(datecol,'MM')
ORDER BY TRUNC(datecol,'MM'); Received on Thu Mar 27 2003 - 11:51:54 CET

Original text of this message