DKN2101 (4/24/2013)
Syntax error.If i do:
SELECT MAX(Revenue_Spend) AS "Largest Amount Spent" FROM MaxCents
I get the max amount spent, but I can't figure out how to get it to display the userID as well.
How about this?
with MaxCents (UserID, Revenue_Spend) as
(
select
UserID,
SUM(Cents) TotalCents
from
DollarTransactions
where
createdDate >= '2012-12-01'
and createdDate < '2013-01-01'
group by
UserID
)
select top (1)
UserID,
TotalCents
from
MaxCents
order by
TotalCents desc;