pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL query (general)
2+ messages / 2 participants
[nested] [flat]
* SQL query (general)
@ 2002-02-19 13:57 D'laila Pereira <dlailap@home.com>
0 siblings, 1 reply; 2+ messages in thread
From: D'laila Pereira @ 2002-02-19 13:57 UTC (permalink / raw)
To: pgsql-sql
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.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: SQL query (general)
@ 2002-02-21 22:09 Jean-Luc Lachance <jllachan@nsd.ca>
parent: D'laila Pereira <dlailap@home.com>
0 siblings, 0 replies; 2+ messages in thread
From: Jean-Luc Lachance @ 2002-02-21 22:09 UTC (permalink / raw)
To: D'laila Pereira <dlailap@home.com>; +Cc: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-02-21 22:09 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-19 13:57 SQL query (general) D'laila Pereira <dlailap@home.com>
2002-02-21 22:09 ` Jean-Luc Lachance <jllachan@nsd.ca>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox