Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
aswinjames
Starting Member
5 Posts |
Posted - 2010-12-20 : 08:21:54
|
Hey, I have a table as follows Customer|Product|w1|w2|w3|w4|w5|w6C1|p1|10|10|10|20|20|40 The required output must be likeCust|prod|WeekStart|weekend|voluneC1 |p1|w1|w3|10C1|p1|w4|w5|20C1|p1|w6|w6|40 One thing that needs to be done is UN pivoting.How do I come up with week start and end dates..Aswin James |
|
aswinjames
Starting Member
5 Posts |
Posted - 2010-12-20 : 10:58:40
|
read 15 times!!but no replies stillis the statement not clear?Aswin James |
 |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
|
aswinjames
Starting Member
5 Posts |
Posted - 2010-12-20 : 12:04:07
|
Thanks jim, Well, I have a source tablecreate table(customerid char, productid char, week1 int ,week2 int ,week3 int,week4 int,week5 int)where the week column would hold the volume of products the table would look as follows after applying a select statmentc1,p1,10,10,10,20,30My O/p must be as followsCustid,productid, Weekstart,weekend, Volumec1, p1,w1,w3,10c1,p1,w4,w4,20c1,p1,w5,w5,30Here repetitive volume would be avoided, The first row of the target table would be able to tel me that from w1 to w3 i had a volume of 10.How do i achieve this?Aswin James |
 |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-12-20 : 13:06:44
|
And I bet this needs to be done dynamically - where the week starts and ends can change?JimEveryday I learn something that somebody else already knew |
 |
|
aswinjames
Starting Member
5 Posts |
Posted - 2010-12-21 : 00:54:48
|
Jim, The weekdates cant change, the week column is a integer field which has the details of the volume sold.YA it needs to be sold dynamically.But how?Aswin James |
 |
|
|
|
|
|
|