| From: | Jean-Luc Lachance <jllachan(at)nsd(dot)ca> |
|---|---|
| To: | "D'laila Pereira" <dlailap(at)home(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: SQL query (general) |
| Date: | 2002-02-21 22:09:12 |
| Message-ID: | 3C757008.563010AF@nsd.ca |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Why don't you write in words what you are trying to accomplish.
To me, it looks like the query should be:
select * from R where a2 > a1;
D'laila Pereira wrote:
>
> i have the following table R
> id a1 a2
> 1 A B
> 2 A B
> 3 B C
> 4 C A
> 5 B C
>
> and to write q uery thats outputs the following
> id a1 a2
> 1 A B
> 2 A B
> 3 B C
> 5 B C
>
> Is the following query correct?
> select *
> from (select *
> from R
> groupby a1) as T1,
> (select *
> from R
> groupby a1) as T2,
> where T1.id<>T2.id
> AND T1.a1=T2.a1
> AND T1.a2=T2.a2;
>
> please correct.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Josh Berkus | 2002-02-21 22:14:38 | Permanent fatal errors |
| Previous Message | Jean-Luc Lachance | 2002-02-21 21:55:04 | Re: maximum of sums |