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
* Tom Lane:
> Florian Weimer <[EMAIL PROTECTED]> writes:
>> For each value in the first column, I need one (and only one) matching
>> row from the table. A possible solution is:
>
> SELECT DISTINCT ON would do it, if you don't mind a non-portable solution.
Cool, thanks a lot.
--
Florian Weimer
Florian Weimer <[EMAIL PROTECTED]> writes:
> For each value in the first column, I need one (and only one) matching
> row from the table. A possible solution is:
SELECT DISTINCT ON would do it, if you don't mind a non-portable solution.
regards, tom lane
am Tue, dem 06.03.2007, um 16:03:36 +0100 mailte Florian Weimer folgendes:
> Is there a better way to implement this?
DISTINCT ON()
http://www.postgresql.org/docs/current/static/sql-select.html#SQL-DISTINCT
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (me
I've got the following table:
fweimer=> SELECT * FROM tab;
a | b | c
---+---+---
1 | 2 | 3
5 | 6 | 7
1 | 2 | 2
2 | 3 | 4
1 | 2 | 2
2 | 3 | 4
For each value in the first column, I need one (and only one) matching
row from the table. A possible solution is:
a | b | c
---+---+---
5 | 6 |