Message-Id: <10701.123702@fatcity.com> From: "Shaw, Glen" Date: Tue, 5 Dec 2000 14:07:27 -0500 Subject: RE: group by week Andrey, Assuming the registration_date field is already a date field, you don't need to do the to_date(to_char( process. Next assumption is that you want Sunday to be day 1 of the week. If you want to start on Monday, just add 2 instead of 1. That being said, the following group by should work for you. select trunc(registration_date, 'WW')+1 REG_DATE, count(status) from AAA group by trunc(registration_date, 'WW')+1; Hope this helps, Glen -----Original Message----- From: andrey [mailto:bronfin@visualtop.com] Sent: Tuesday, December 05, 2000 1:23 PM To: oralist@lists; ORACLE-L@IC.SUNYSB.EDU; ORACLE-L@fatcity.com; oracledba@quickdoc.co.uk; oracledba@lazydba.com Subject: group by week Dear list ! I have a table AAA with fields (registration_date , status ) . I need a report which will group the results by week . I.e instead of select to_date(to_char(REGISTRATION_DATE,'DD-MON-YYYY')), count(status) from AAA group by to_date(to_char(REGISTRATION_DATE,'DD-MON-YYYY')); I need something like select first_date_in_the_week(REGISTRATION_DATE) , count(status) from AAA group by week_of ( REGISTRATION_DATE ) ;