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 |
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2008-01-14 : 15:03:14
|
| Lamprey helped me solve a summation problem last time thank!http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95164I have a variation of the problem i can not find a way to solve please helpProblemI have a table: amount group startdate enddate23 g1 12/1/2005 1/2/200636 g2 12/1/2005 12/20/200645 g1 12/8/2005 1/3/300787 g1 12/10/2005 12/26/300767 g1 12/6/2005 12/18/3007------the earliest start date is 12/1/2005 and latest enddate is 1/10/2006I WANT TO GET sum of amount of each day from 12/1/2005 to 1/10/2006the result should likedate group sumamount12/1/2005 g1 234612/1/2005 g2 282312/2/2005 g1 345612/2/2005 g2 230---12/20/2005 g2 654----for 12/1/2005, g1 the sumamount is sum of amount for all records with startdate<12/1/2005 and enddate >12/1/2005 for g1for 12/1/2005, g2 the sumamount is sum of amount for all records with startdate<12/1/2005 and enddate >12/1/2005 for g2for 12/20/2005, g1 the sumamount is sum of amount for all records with startdate<12/20/2005 and enddate >12/20/2005 for g1for 12/20/2005, g2 the sumamount is sum of amount for all records with startdate<12/20/2005 and enddate >12/20/2005 for g2How can i have a query to do that?Thank you very much for any suggestionsJeff |
|
|
|
|
|