Re: Postgres-sql-php - Mailing list pgsql-sql

From Oliveiros Cristina
Subject Re: Postgres-sql-php
Date
Msg-id f54607780810231100v47bbd430h96ddafa7906dad02@mail.gmail.com
Whole thread Raw
In response to Postgres-sql-php  ("Zied Kharrat" <khzied@gmail.com>)
List pgsql-sql

I guess you can change a little the query to your needs.
The problem is pretty much the same...
I've used c3 column in equality, but if this column
has repeated values, just choose any column or combination of columns which is unique.

Best,
Oliveiros

SELECT a.c1,a.c2,b.c3,b.c4,a.c5,b.c6
FROM
(
SELECT c1,c2,c5, MIN(c3)as primeira
FROM t1
GROUP BY c1,c2,c5
) a
RIGHT JOIN t1 b
ON b.c3 = a.primeira
AND b.c1 = a.c1
AND a.c2 = b.c2
AND a.c5 = b.c5

2008/10/23 Zied Kharrat <khzied@gmail.com>
Really, i have this schema:

c1     c2     c3      c4     c5      c6
v1     v2     v3      v4     v5      v6
v1     v2     v7      v8     v5      v9
v1     v2     v10    v11    v5      v12

how can i do my sql request to obtain this?

c1     c2     c3      c4     c5      c6
v1     v2     v3      v4     v5      v6
                 v7      v8               v9
                 v10    v11             v12


Thank u very much :)



--
even the biggest failure, even the worst mistake, beats the hell out of never trying...
- Meredith Grey

pgsql-sql by date:

Previous
From: Steve Midgley
Date:
Subject: Re: grouping/clustering query
Next
From: Joe
Date:
Subject: Re: grouping/clustering query