Received: from BLAHFASEL.Triestram-Partner.de (elvis.triestram-partner.de [212.185.173.195]) by hub.org (8.10.1/8.10.1) with ESMTP id e597GCT93404 for ; Fri, 9 Jun 2000 03:16:12 -0400 (EDT) Received: by BLAHFASEL with Internet Mail Service (5.5.2650.21) id ; Fri, 9 Jun 2000 09:16:13 +0200 Message-ID: <4094ADEA26D8D3119F020000D1106EC4061711@BLAHFASEL> From: Oliver Graf To: Bernie Huang , PGSQL-SQL Subject: RE: SQL 'Case When...' Date: Fri, 9 Jun 2000 09:16:10 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain X-Archive-Number: 200006/100 > Don't know if it's possible, but how do I make the following SQL > statments right? > > select attribute[1] > from table > case when attribute[1]='yes' > then select attribute[2] from table > else select attribute[3] from table; > > Basically, I want to compare attr[1], if true then select some fields > from table; if false then select others. Try this: select case attribute[1] when 'yes' then attribute[2] else attribute[3] end from table; -- Oliver Graf Triestram & Partner GmbH Kohlenstr. 55, 44795 Bochum, Germany Phone +49 234 94375-15 Fax +49 234 452206 eMail: O.Graf@t-p.com http://www.t-p.com