From: | "Oliveiros Cristina" <oliveiros(dot)cristina(at)gmail(dot)com> |
---|---|
To: | "Zied Kharrat" <khzied(at)gmail(dot)com> |
Cc: | "Oliveiros Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Postgres-sql-php |
Date: | 2008-10-23 18:00:54 |
Message-ID: | f54607780810231100v47bbd430h96ddafa7906dad02@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 primeiraFROM 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(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Joe | 2008-10-23 18:28:33 | Re: grouping/clustering query |
Previous Message | Steve Midgley | 2008-10-23 16:08:48 | Re: grouping/clustering query |