Am Dienstag, 6. März 2007 16:03 schrieb Florian Weimer:
> a | b | c
> ---+---+---
> 5 | 6 | 7
> 2 | 3 | 4
> 1 | 2 | 3
Hi,
couldn't you accomplish this by:
select distinct on (a) * from tablename order by a;
here:
create table tab (a int,b int,c int);
insert into tab values (1,2,3);
insert into tab values (5,6,7);
insert into tab values (1,2,3);
insert into tab values (2,3,4);
insert into tab values (1,2,2);
insert into tab values (2,3,4);
select * from tab;a | b | c
---+---+---1 | 2 | 35 | 6 | 71 | 2 | 32 | 3 | 41 | 2 | 22 | 3 | 4
(6 rows)
select distinct on (a) * from tab order by a;a | b | c
---+---+---1 | 2 | 32 | 3 | 45 | 6 | 7
(3 rows)
my regards,
Stefan
--
email: stefan@yukonho.de
tel : +49 (0)6232-497631
http://www.yukonho.de