pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcomparing 2 queries
2+ messages / 2 participants
[nested] [flat]
* comparing 2 queries
@ 2003-05-15 13:48 Martin Marques <martin@bugs.unl.edu.ar>
0 siblings, 1 reply; 2+ messages in thread
From: Martin Marques @ 2003-05-15 13:48 UTC (permalink / raw)
To: pgsql-sql
I have to queries that return INT values, and I want to know if one is
less or equal to the other.
Is it posible to put it all in one query and have a return of 1 or 0?
I tried somethings with CASE, but it didn't work.
--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: comparing 2 queries
@ 2003-05-15 14:56 Richard Huxton <dev@archonet.com>
parent: Martin Marques <martin@bugs.unl.edu.ar>
0 siblings, 0 replies; 2+ messages in thread
From: Richard Huxton @ 2003-05-15 14:56 UTC (permalink / raw)
To: Martin Marques <martin@bugs.unl.edu.ar>; pgsql-sql
On Thursday 15 May 2003 2:48 pm, Martin Marques wrote:
> I have to queries that return INT values, and I want to know if one is
> less or equal to the other.
> Is it posible to put it all in one query and have a return of 1 or 0?
> I tried somethings with CASE, but it didn't work.
Assuming each query returns only one row, something like the following (note
the brackets around the sub-selects and the fact they've been aliased).
=# SELECT (a.value1=b.value2) FROM (SELECT 100 as value1) as a, (SELECT 200 as
value2) as b;
?column?
----------
f
(1 row)
=# SELECT (a.value1=b.value2) FROM (SELECT 200 as value1) as a, (SELECT 200 as
value2) as b;
?column?
----------
t
(1 row)
--
Richard Huxton
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-05-15 14:56 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-15 13:48 comparing 2 queries Martin Marques <martin@bugs.unl.edu.ar>
2003-05-15 14:56 ` Richard Huxton <dev@archonet.com>
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