|
Posted by ree321 on 08/22/06 23:22
Thanks that worked great when I changed the SUM(a.Amount) to
Max/Min(a.Amount) as I want the latest amount and not the sum of the
Amounts.
Hugo Kornelis wrote:
> On 21 Aug 2006 23:26:25 -0700, ree321@gmail.com wrote:
>
> Hi ree321,
>
> Try if this works:
>
> SELECT TOP 10 a.Project, SUM(a.Amount) AS TotalAmount
> FROM YourTable AS a
> WHERE a.Date = (SELECT MAX(b.Date)
> FROM YourTable AS b
> WHERE b.Project = a.Project)
> GROUP BY a.Project
> ORDER BY TotalAmount DESC
>
> (Untested - see www.aspfaq.com/5006 if you prefer a tested reply)
>
> --
> Hugo Kornelis, SQL Server MVP
Navigation:
[Reply to this message]
|