Re: comparing 2 queries

From: Richard Huxton <dev(at)archonet(dot)com>
To: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>, pgsql-sql(at)postgresql(dot)org
Subject: Re: comparing 2 queries
Date: 2003-05-15 14:56:15
Message-ID: 200305151556.15716.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-05-15 15:42:33 Re: Calculating Percentages
Previous Message Stephan Szabo 2003-05-15 14:49:17 Re: check with select