Re: problems selecting multiple records (again!) - Mailing list pgsql-novice

From Nabil Sayegh
Subject Re: problems selecting multiple records (again!)
Date
Msg-id 991256231.4513.2.camel@billy.labor.localnet
Whole thread Raw
In response to problems selecting multiple records (again!)  ("Giorgio A." <jh@libero.it>)
List pgsql-novice
On 30 May 2001 21:57:45 +0200, Giorgio A. wrote:
> but what i really wanted was :
>
> 1  |  10  | 2001-05-10
> 4  |  20  |  2001-05-11
> 6  |  30  |  2001-05-15

CREATE TEMP TABLE tmp (ref int, dat date);
INSERT INTO tmp values (10, '2001-05-10');
INSERT INTO tmp values (10, '2001-05-11');
INSERT INTO tmp values (10, '2001-05-12');
INSERT INTO tmp values (20, '2001-05-11');
INSERT INTO tmp values (20, '2001-05-13');
INSERT INTO tmp values (30, '2001-05-15');
SELECT ref, min(dat) from tmp group by ref order by min(dat) limit 3;

 ref |    min
-----+------------
  10 | 10.05.2001
  20 | 11.05.2001
  30 | 15.05.2001
(3 rows)

--
 Nabil Sayegh



pgsql-novice by date:

Previous
From: "Giorgio A."
Date:
Subject: problems selecting multiple records (again!)
Next
From: Chadwick Rolfs
Date:
Subject: Table creation