SQL query to group data by Code and dates
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