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 |
Akshaya Pargunan
Starting Member
10 Posts |
Posted - 2011-10-11 : 06:58:55
|
my date in databaseMonday Tuesday Wednesday Thursday Friday Saturday Sunday WeekEndDate------ ------- --------- -------- ------ -------- ------ -----------2 0 0 0 5 8 0 02/10/20110 3 0 0 0 0 0 09/10/20113 0 2 0 0 0 0 16/10/20110 0 0 1 0 8 9 23/10/20110 0 0 0 0 6 0 30/10/2011i have to generate result like belowthe [date of request] (having values,remove all the 0 entries) in the first column based on weekenddate and the correspoding values on the second column [hoursused]dateofrequest hoursused----------------- --------------26/09/2011 230/09/2011 501/10/2011 804/10/2011 310/10/2011 312/10/2011 220/10/2011 122/10/2011 823/10/2011 928/10/2011 6 |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-10-11 : 07:15:15
|
select WeekEndDate - 6, Monday where Monday > 0union allselect WeekEndDate - 5, Tuesday where Tuesday > 0union all...==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
Akshaya Pargunan
Starting Member
10 Posts |
Posted - 2011-10-11 : 08:56:16
|
Thanks a lot for the informationit helped me lot |
|
|
|
|
|