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-10 : 08:19:48
|
I have table like belowMonday Tuesday Wednesday Thursday Friday Saturday Sunday WeekEndDate------ ------- --------- -------- ------ -------- ------ -----------2 3 2 5 5 8 0 02/10/20110 3 7 1 0 2 4 09/10/20113 0 2 0 5 0 6 16/10/20112 3 0 1 0 8 9 23/10/20111 6 2 4 0 3 0 30/10/2011Weekenddate has sunday's date,the row has one week date from monday to sunday.I have two inputsfromdate = 06/10/201 todate = 20/10/2011how can return sum(monday),sum(tusday),sum(wednesday),sum(thursday),sum(friday),sum(saturday),sum(sunday) with in these two dates from the table above? |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-10 : 08:41:30
|
use a expression based on DATEPART(dw,GETDATE()) likeSUM(CASE WHEN DATEPART(dw,GETDATE()) =1 THEN Yourfield else 0 end),SUM(CASE WHEN DATEPART(dw,GETDATE()) =2 THEN Yourfield else 0 end),...------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-10-10 : 08:47:54
|
I gave an answer to this post in the referenced post above giving a couple of suggestions depending on what the requirement really is - seems to have been deleted. I hope the OP has a copy of that solution and can post it wherever he wants to continue the thread as I'm not going to repost it.==========================================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-10 : 09:03:42
|
its saying i dont have access to this post |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-10-10 : 09:50:01
|
Didn't you delete it? It sems to have gone. Otherwise it sounds like a forum bug.==========================================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. |
|
|
|
|
|
|
|