Subject RE: [firebird-support] SQL Query Help
Author Ryan Thomas
Hi Erik,

> 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?

You should be able to do it with something like this:

SELECT ProductID, MAX(SaleDate) FROM THE_TABLE GROUP BY 1 ORDER BY 1 ASC

Cheers,

-Ryan


> Please any advices.
>
> Thanks in advance.
>
> Erik
> ____
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> Get fast access to your favorite Yahoo! Groups. Make Yahoo!
> your home page
> http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/67folB/TM
> --------------------------------------------------------------
> ------~->
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>