X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AE09152B8A for ; Thu, 18 Aug 2005 22:32:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29910-01 for ; Fri, 19 Aug 2005 01:32:22 +0000 (GMT) Received: from TWMAIL.ESNCC.COM (static-66-173-159-28.t1.cavtel.net [66.173.159.28]) by svr1.postgresql.org (Postfix) with ESMTP id 8C75D52B63 for ; Thu, 18 Aug 2005 22:32:18 -0300 (ADT) Received: from spawar2i8uvlb9 ([150.125.117.63]) by TWMAIL.ESNCC.COM with Microsoft SMTPSVC(5.0.2195.6713); Thu, 18 Aug 2005 21:32:22 -0400 From: "Lane Van Ingen" To: Subject: SQL CASE Statements Date: Thu, 18 Aug 2005 21:31:34 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 Importance: Normal X-OriginalArrivalTime: 19 Aug 2005 01:32:22.0092 (UTC) FILETIME=[D87D20C0:01C5A45D] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.083 required=5 tests=[AWL=0.033, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/154 X-Sequence-Number: 22382 In the following CASE statement, is it possible to put a SELECT ... WHERE EXISTS in the of a CASE statement, and have it work? The I want to do is to yield a result of '1' if the statement finds the value 'a' in a table (EXISTS evaluates true), and '0' if it evaluates false ('a' not found). SELECT a, CASE WHEN THEN 1 ELSE 0 END Has anybody done this? If so, can you send me a sample?