From: Halley Pacheco de Oliveira <halleypo@yahoo.com.br>
To: pgsql-sql@postgresql.org
Cc: lvaningen@esncc.com
Subject: Re: SQL CASE Statements
Date: Sat, 20 Aug 2005 11:25:16 +0000 (GMT)
Message-ID: <20050820112516.43689.qmail@web52714.mail.yahoo.com> (raw)
> Has anybody done this? If so, can you send me a sample?
CREATE TEMPORARY TABLE fruits (id SERIAL, name TEXT);
INSERT INTO fruits VALUES (DEFAULT, 'banana');
INSERT INTO fruits VALUES (DEFAULT, 'apple');
CREATE TEMPORARY TABLE food (id SERIAL, name TEXT);
INSERT INTO food VALUES (DEFAULT, 'apple');
INSERT INTO food VALUES (DEFAULT, 'spinach');
SELECT name, CASE WHEN name = ANY (SELECT name FROM fruits)
THEN 'yes'
ELSE 'no'
END AS fruit
FROM food;
name | fruit
---------+-------
apple | yes
spinach | no
(2 lines)
__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: halleypo@yahoo.com.br, lvaningen@esncc.com
Subject: Re: SQL CASE Statements
In-Reply-To: <20050820112516.43689.qmail@web52714.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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