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 |
|
Lacool
Starting Member
2 Posts |
Posted - 2010-03-04 : 19:49:20
|
| Hi, I have a query which SUMS the values of a couple of columns as per below. I want to be able to SUM the results of 'Total Loc Fee' and 'Total Card Fee', is this possible in the same query.SELECT UserName, DateInserted, SUM(NoLocations * 1.50) AS 'Total Loc Fee', SUM(CardFee * 11.00) AS 'Total Card Fee'FROM dbo.tblChargeHistoryGROUP BY UserName, DateInsertedMany Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-04 : 22:49:58
|
[code]SELECT UserName, DateInserted, SUM(NoLocations * 1.50) AS 'Total Loc Fee', SUM(CardFee * 11.00) AS 'Total Card Fee', SUM(SUM(NoLocations * 1.50)) over () as [Grand Total Loc Fee], SUM(SUM(CardFee * 11.00)) over () as [Grand Total Card Fee]FROM dbo.tblChargeHistoryGROUP BY UserName, DateInserted[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Lacool
Starting Member
2 Posts |
Posted - 2010-03-06 : 00:19:04
|
| Many thanks, your help is appreciated |
 |
|
|
|
|
|
|
|