Re: problems selecting multiple records (again!)

From: Nabil Sayegh <nsmail(at)sayegh(dot)de>
To: Giorgio "A(dot)" <jh(at)libero(dot)it>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: problems selecting multiple records (again!)
Date: 2001-05-30 20:57:11
Message-ID: 991256231.4513.2.camel@billy.labor.localnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Chadwick Rolfs 2001-05-30 21:47:04 Table creation
Previous Message Giorgio A. 2001-05-30 19:57:45 problems selecting multiple records (again!)