SQL Question

From: Alex <alex(at)meerkatsoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: SQL Question
Date: 2005-04-15 11:58:31
Message-ID: 425FAC67.2050203@meerkatsoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

i have a table

ProdId | LastUpdate
-------+------------
100 | 2005-04-01
100 | 2005-03-01
100 | 2005-02-01
200 | 2005-04-01
200 | 2005-03-01
200 | 2005-02-01

- How can i select only the newest record for each ProdId ?

100 | 2005-04-01
200 | 2005-04-01

- How can i select to retrieve the last 2 dates in record

100 | 2005-04-01 | 2005-03-01
200 | 2005-04-01 | 2005-03-01

Thanks
Alex

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alejandro D. Burne 2005-04-15 12:13:40 If statements on select
Previous Message Thomas Hallgren 2005-04-15 09:03:19 Re: PostgreSQL 8.0.2 Now Available