Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: count by month
Sorry, I goofed a bit, a better example would be :
> > sale saledate
> > 12 01/16/2001
> > 33 02/05/2001
> > 2 03/15/2001
so I can ask:
select count(*)
from table1
where saledate >= (to_date('03-01-2001', 'MM-DD-YYYY')
and saledate < (to_date('04-01-2001', 'MM-DD-YYYY')
But I thought "there has to be a better way". I want to group by the
month of the date field. So I would have the count of all the sales by
month without having to write 12 queries. Sorry for mis posting the
first time. I don't see how I can do this without an Oracle
GRAB_MONTH_FROM_DATE function but I don't know much about SQL as is
obvious.
ben
Received on Thu Aug 30 2001 - 21:07:11 CDT