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