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 |
|
craigmacca
Posting Yak Master
142 Posts |
Posted - 2008-01-10 : 15:27:46
|
| Hi i have query which i need to add a sum to but not sure how as i keep getting a ambiguous error!!i need a sum(cost)as newcostfrom this querySELECT tmp.ID, tmp.Cost, tmp.DateofSM, tmp.MessageText, tmp.GroupMessageID,tmp.ClubID,tmp.RCODEFROM( SELECT t1.ID, t1.Cost, t1.DateofSM, t1.ClubID, t1.MessageText, t1.GroupMessageID, t1.RCODE, ( SELECT COUNT(*) + 1 FROM SMS_Records WHERE GroupMessageID=t1.GroupMessageID AND ID <t1.ID ) AS 'RowNo' FROM SMS_Records t1)tmpWHERE tmp.RowNo=1 AND DATENAME(month, DateOfSM)= @DateAND ClubID = @ClubID |
|
|
gavakie
Posting Yak Master
221 Posts |
Posted - 2008-01-10 : 15:35:57
|
| you need a group by |
 |
|
|
|
|
|