Subject | Re: SQL Query Help - more |
---|---|
Author | Adam |
Post date | 2005-11-17T22:07:16Z |
> First THANKS Adam & Ryan:product.
>
> It works if table has only those 2 fields,
> but the table has more columns: PrID, Description, Unit, Qty, Price,
> SaleDate.
> So, Im interested in obtain the complete 'LAST' row of every sold
>Erik,
> Again, thanks in advance, my best 4 U,
>
> Erik
Just include all of the fields that are not aggregates (eg max) in the
group by.
---
select PrID, Description, Unit, Qty, Price, max(SaleDate) as LastSaledate
from WhateverYourTableIsCalled
group by PrID, Description, Unit, Qty, Price
---
You can also use an order by clause after the group by to order the
results a particular way.
Adam