Re: SQL CASE Statements - Mailing list pgsql-sql

From Halley Pacheco de Oliveira
Subject Re: SQL CASE Statements
Date
Msg-id 20050820112516.43689.qmail@web52714.mail.yahoo.com
Whole thread Raw
In response to SQL CASE Statements  ("Lane Van Ingen" <lvaningen@esncc.com>)
Responses Re: SQL CASE Statements  ("Lane Van Ingen" <lvaningen@esncc.com>)
List pgsql-sql
> 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   | yesspinach | no
(2 lines)


__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger 
http://br.download.yahoo.com/messenger/ 


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: PGSQL function for converting between arbitrary numeric bases?
Next
From: Moritz Bayer
Date:
Subject: Problem with self-made plpgsql-function / casting