Subject SQL Query Help - more
Author Erik Raul Chan Silveira
--- In firebird-support@yahoogroups.com, "Adam" <s3057043@y...> wrote:
>
> --- In firebird-support@yahoogroups.com, "Erik Raul Chan Silveira"
> <echan@s...> wrote:
> >
> > Hello People:
> > (if this msg is a off topic, pardon me, point me to another list)
> >
> > I would like your help with a query, I have the next data:
> >
> > ProductID SaleDate (m/d/Y)
> > Pr1 05/05/2005
> > Pr1 06/01/2005
> > Pr2 01/01/2005
> > Pr2 10/15/2005
> > ...
> > Pr1 10/29/2005
> > Pr2 10/16/2005
> > ...
> > Pr3 10/01/2005
> > ...
> >
> >
> > I wanna obtain a resulset with all products and its last (most
> recent)
> > SaleDate,
> > something like:
> > ProductID SaleDate
> > Pr1 10/29/2005
> > Pr2 10/16/2005
> > Pr3 10/01/2005
> >
> > may i accomplish it with one (maybe complex) query or should I make
> a
> > stored procedure?
>
> Erik,
>
> Unless there is something I am not considering, it looks like a
> simple group by.
>
> select ProductID, max(SaleDate) as LastSaledate
> from WhateverYourTableIsCalled
> group by ProductID
>
>
> Adam
>
First THANKS Adam & Ryan:

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 product.

Again, thanks in advance, my best 4 U,

Erik
____

PD: Im searching for a SQL lists, forums ...