Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query to group dates based on days of week

chkzofrekOct 29 2013 — edited Nov 18 2013

Hi,

I have a table containing the following format:

Create table testtable(dates date, day_identifier number);

The day_identifier column data contains the corresponding dates columns' day of week equivalent i.e.

to_char(dates, 'd')

The table contains following sample data:

DatesDay_identifier
01-Oct-20133
02-Oct-20134
04-Oct-20136
06-Oct-20131
08-Oct-20133
09-Oct-20134
11-Oct-20136
18-Oct-20136
21-Oct-20132
23-Oct-20134

I am looking for a query that will group the above data based on the day_identifier column data into the following format:

01-Oct-2013 11-Oct-2013 1346

18-Oct-2013 23-Oct-2013 246

The above data if expanded i.e.

all dates between 01-Oct-2013 and 11-Oct-2013 and having day of week value in 1,3,4,6

and

all dates between 18-Oct-2013 and 23-Oct-2013 and having day of week value in 2,4,6

will give me the above table's resultset.

Please help me in resolving the issue.

Thanks.

This post has been answered by Etbin on Nov 17 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2013
Added on Oct 29 2013
19 comments
3,320 views