Re: [GENERAL] case expression

2008-09-24 Thread Guy Rouillier
Garry Saddington wrote: It does work but returns a column called case. How can I return the case column as 'postcode'? select CASE WHEN postcode ilike '%OO%' THEN '' END as postcode from addresses -- Guy Rouillier -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] case expression

2008-09-24 Thread Fernando Moreno
> > BTW, should you have an "else" clause in there? - What happens when the > comparison fails? > As Tom said, a null value would be returned.

Re: [GENERAL] case expression

2008-09-24 Thread Raymond O'Donnell
On 24/09/2008 23:22, Garry Saddington wrote: >> Garry Saddington <[EMAIL PROTECTED]> 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

Re: [GENERAL] case expression

2008-09-24 Thread Richard Broersma
On Wed, Sep 24, 2008 at 3:22 PM, Garry Saddington <[EMAIL PROTECTED]> wrote: >> > select *, >> > 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'? You have to give an Alias to thi

Re: [GENERAL] case expression

2008-09-24 Thread Garry Saddington
On Wednesday 24 September 2008 21:03, Tom Lane wrote: > Garry Saddington <[EMAIL PROTECTED]> writes: > > Can anyone tell me why this will not work? > > > > select *, > > CASE WHEN postcode ilike '%OO%' THEN '' > > END > > from addresses > > ... > > Define "not work". What are you expecting it to d

Re: [GENERAL] case expression

2008-09-24 Thread Tom Lane
Garry Saddington <[EMAIL PROTECTED]> writes: > Can anyone tell me why this will not work? > select *, > CASE WHEN postcode ilike '%OO%' THEN '' > END > from addresses > ... Define "not work". What are you expecting it to do versus what really happens? Right offhand it looks like the CASE will r

[GENERAL] case expression

2008-09-24 Thread Garry Saddington
Can anyone tell me why this will not work? select *, CASE WHEN postcode ilike '%OO%' THEN '' END from addresses where studentid=1234 and addresstype='C' There are postcodes like this: OO00 0OO Regards Garry -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make change