Re: case expression - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: case expression
Date
Msg-id 48DABCD6.9020806@iol.ie
Whole thread Raw
In response to case expression  (Garry Saddington <garry@schoolteachers.co.uk>)
Responses Re: case expression  ("Fernando Moreno" <azazel.7@gmail.com>)
List pgsql-general
On 24/09/2008 23:22, Garry Saddington wrote:
>> Garry Saddington <garry@schoolteachers.co.uk> writes:
>>> CASE WHEN postcode ilike '%OO%' THEN ''
>>> END
>>> from addresses
>
> It does work but returns a column called case. How can I return the case
> column as 'postcode'?

...case when postcode ilike '%OO%' then '' end as postcode, ...

BTW, should you have an "else" clause in there? - What happens when the
comparison fails?

Ray.


------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

pgsql-general by date:

Previous
From: "Richard Broersma"
Date:
Subject: Re: case expression
Next
From: "Taras Kopets"
Date:
Subject: Re: problem with custom_variable_classes