X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 86E8F47670A for ; Thu, 15 May 2003 10:56:52 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 21753-07 for ; Thu, 15 May 2003 10:56:20 -0400 (EDT) Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id DEA1047670D for ; Thu, 15 May 2003 10:56:18 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 19GK9b-0003rn-0U; Thu, 15 May 2003 15:56:19 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 3892516350; Thu, 15 May 2003 15:56:18 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 8D890162EC; Thu, 15 May 2003 15:56:17 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Martin Marques , pgsql-sql@postgresql.org Subject: Re: comparing 2 queries Date: Thu, 15 May 2003 15:56:15 +0100 User-Agent: KMail/1.4.3 References: <200305151048.20609.martin@bugs.unl.edu.ar> In-Reply-To: <200305151048.20609.martin@bugs.unl.edu.ar> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200305151556.15716.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/316 X-Sequence-Number: 13481 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 (not= e=20 the brackets around the sub-selects and the fact they've been aliased). =3D# SELECT (a.value1=3Db.value2) FROM (SELECT 100 as value1) as a, (SELECT= 200 as=20 value2) as b; ?column? ---------- f (1 row) =3D# SELECT (a.value1=3Db.value2) FROM (SELECT 200 as value1) as a, (SELECT= 200 as=20 value2) as b; ?column? ---------- t (1 row) --=20 Richard Huxton