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 |
niyaz4872
Starting Member
41 Posts |
Posted - 2015-05-18 : 09:50:45
|
following is my table structureid count date 01 2 2010010104 1 2010010109 5 2010010109 6 2010010109 5 2010010701 8 2010010504 5 2010012501 4 2010020109 8 20100205following is sample results i wan'tid sumcountdate1(between 20100101 and 20100108 ) sumcountdate1(between 20100201 and 20100230 )01 10 404 1 009 16 8 |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2015-05-18 : 17:23:10
|
select id, sum(case when [date] between '20100101' and '20100108' then [count] else 0 end, sum(case when [date] between '20100201' and '20100228' then [count] else 0 end[/code]NOTE: I am assuming that there is no February 30th in 2010. I would rather be the man who bought the Brooklyn Bridge than the one who sold it. -Will Rogers |
|
|
|
|
|