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!

SQL query to group data by Code and dates

Ryansun-OracleJun 7 2012 — edited Jun 8 2012
Hi There,

I have the following table structure

col1 col2 col3
code1 21-jan-2012 tested
code1 20-jan-2012 tested
code1 01-jun-2012 tested
code2 01-jun-2012 tested
code3 04-jun-2012 tested

so on

The output should be some thing like

code Week1 week2 week 3 week4 week5 till about last 14 weeks from the date we are running
code1 1 0 0 0 0
code2 1 0 0 0 0
code 3 0 1 0 0 0

where 1, 0 is actually the counts and not sum and the week in this case, should have maybe been since we are in the second week it should have been

code .....................week3 may week4 may week1 jun week2june


Was looking for suggestions on how to get this done.

I am assuming this would require some sort of a pivot query?

Thanks,
Sun
This post has been answered by Frank Kulash on Jun 7 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2012
Added on Jun 7 2012
16 comments
745 views