Re: [GENERAL] how to return field based on field= NULL or not

2009-08-24 Thread Sam Mason
On Mon, Aug 24, 2009 at 12:54:31PM +0200, Alban Hertroys wrote: > CASE > WHEN fieldA IS NOT NULL THEN fieldA > WHEN fieldB IS NOT NULL THEN fieldB > WHEN fieldC IS NOT NULL THEN fieldC > ELSE fieldD > END BTW, the above expression is identical to: COALESCE(fiel

Re: [GENERAL] how to return field based on field= NULL or not

2009-08-24 Thread Alban Hertroys
On 24 Aug 2009, at 7:50, Scott Marlowe wrote: On Sun, Aug 23, 2009 at 11:43 PM, Juan Backson wrote: Hi, Thank you for your help. What I want to dos is as follows: SELECT COALESCE(fieldA::text,fieldB||fieldC||fieldD) from ring where group_id = 1 if fieldB is NULL, i will want it to return f

Re: [GENERAL] how to return field based on field= NULL or not

2009-08-23 Thread Scott Marlowe
On Sun, Aug 23, 2009 at 11:43 PM, Juan Backson wrote: > Hi, > > Thank you for your help. > > What I want to dos is as follows: > > SELECT COALESCE(fieldA::text,fieldB||fieldC||fieldD) from ring where > group_id = 1 > > if fieldB is NULL, i will want it to return fieldC|| fieldD > if fieldB and fiel

Re: [GENERAL] how to return field based on field= NULL or not

2009-08-23 Thread Juan Backson
Hi, Thank you for your help. What I want to dos is as follows: SELECT COALESCE(fieldA::text,fieldB||fieldC||fieldD) from ring where group_id = 1 if fieldB is NULL, i will want it to return fieldC|| fieldD if fieldB and fieldC is null, I want it to return fieldD. Basically, fieldD is always goi

Re: [GENERAL] how to return field based on field= NULL or not

2009-08-23 Thread Wojtek
Hi, I assume one field will always be NULL and one will always has data in it. select coalesce(fieldA, fieldB) from table Regards, foo Juan Backson wrote: Hi, In my table, I have fieldA and fieldB. At any point in time, only one of these fields can have data in it. The other is NULL. I

Re: [GENERAL] how to return field based on field= NULL or not

2009-08-23 Thread Adam Rich
Juan Backson wrote: Hi, In my table, I have fieldA and fieldB. At any point in time, only one of these fields can have data in it. The other is NULL. Instead of "select fieldA, fieldB from table", I want it to return either fieldA or fieldB depends on whether it is NULL or not. The re

[GENERAL] how to return field based on field= NULL or not

2009-08-23 Thread Juan Backson
Hi, In my table, I have fieldA and fieldB. At any point in time, only one of these fields can have data in it. The other is NULL. Instead of "select fieldA, fieldB from table", I want it to return either fieldA or fieldB depends on whether it is NULL or not. The reason is because I want to use