| От | Condor |
|---|---|
| Тема | Need help with SQL query and finding NULL array_agg |
| Дата | |
| Msg-id | 040c7ebd998bb6352cda33663d06b463@stz-bg.com обсуждение |
| Ответы |
Re: Need help with SQL query and finding NULL array_agg
|
| Список | pgsql-general |
Hello ppl, I have a problem with one sql query, can some one help me. My query is: SELECT array_agg(month) AS month, array_agg(status) AS status, array_agg(service) AS service, case when array_upper(array_agg(phone), 1) is not null THEN array_agg(phone) else array_agg(mobile) END FROM bills WHERE status > 1 GROUP BY mobile I try with simple query to identify did array_agg(phone) is empty or null and if is it to return me mobile field, if not empty to return me phone. Mobile field exist always, but phone may exists for that mobile may not exists. One mobile can have few services like: mob service phone 1321543434 64 1321543434 66 13255555 I try few thing but sql only return me records that phone is not empty, but I need them both. Any one has ideas what I can do ?
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера