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 |
|
Geneoh
Starting Member
4 Posts |
Posted - 2004-07-08 : 17:24:51
|
| Hi all,I am need of some of your collective expertise.I have a table with the following fieldsMemberIDTransDateAmountI need to use a stored procedure to pull a SUM(amount) For a date range from parameters such as TRansDate >=@startDate and TRansDate <=@endDate .My problem is that this keeps breaking on each individual date so that I end up with a Sum of amount for each date in the date range. I need it to not break on each date so that I can then sort on the Sum(amount) Expression this is to allow my to get a high spender result for the time period in question.Any help would be greatly appreciatedGene |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-07-08 : 18:19:26
|
Something like:SELECT MemberID,SUM(Amount) TTL_AmountFROM( SELECT MemberID, TransDate, Amount FROM Table WHERE TransDate between @startdate and @enddate) dGROUP BY MemberID ) d[/code] |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-07-08 : 18:24:53
|
| select memberid, sum(amount) ttl_amountfrom tablewhere transdate between @startdate and @enddategroup by memberid |
 |
|
|
|
|
|