Home Forums SQL Server 2008 SQL Server 2008 - General how to find max amount RE: how to find max amount
TakeITeasy
SSC Enthusiast
Points: 181
More actions
August 27, 2010 at 10:52 am
#1213107
Hi, Change @t to your table name and your columns for id, amount, adate
WITH cte AS
(
SELECT ROW_NUMBER() OVER (PARTITION BY id ORDER BY adate desc) AS ROW,
id,
amount,
adate
FROM @t
)
SELECT *
FROM cte
where Row = 1
this should work fine.