| От | Scott Marlowe |
|---|---|
| Тема | Re: how to return field based on field= NULL or not |
| Дата | |
| Msg-id | dcc563d10908232250y28679beds94fbcb7799cba72b@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: how to return field based on field= NULL or not (Juan Backson <juanbackson@gmail.com>) |
| Ответы |
Re: how to return field based on field= NULL or not
|
| Список | pgsql-general |
On Sun, Aug 23, 2009 at 11:43 PM, Juan Backson<juanbackson@gmail.com> 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 fieldC is null, I want it to return fieldD. > > Basically, fieldD is always going to have data, but fieldB and fieldC can be > NULL. > > How can I revise the query to meet that purpose? Just coalesce them all to '' and cat them: ... coalesce(a,'')||coalesce(b,'')||coalesce(c,'')||d ...
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера