Re: BUG #15208: COALESCE with CTE returns NULL

From: Sergei Kornilov <sk(at)zsrv(dot)org>
To: "klaxian(at)gmail(dot)com" <klaxian(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15208: COALESCE with CTE returns NULL
Date: 2018-05-25 16:24:42
Message-ID: 494321527265482@myt2-66bcb87429e6.qloud-c.yandex.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello
I can not reproduce

psql (10.4 (Debian 10.4-1.pgdg80+1))
Type "help" for help.

postgres=# WITH test_cte AS (SELECT 1 AS id, 2 AS qty)
SELECT COALESCE(SUM(qty), 0) FROM test_cte WHERE id=2;
coalesce
----------
0
(1 row)

postgres=# WITH test_cte AS (SELECT 1 AS id, 2 AS qty)
SELECT COALESCE((SELECT SUM(qty) FROM test_cte WHERE id=2), 0);
coalesce
----------
0
(1 row)

Can you give more complete example?

regards, Sergei

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-05-25 16:24:44 Re: BUG #15208: COALESCE with CTE returns NULL
Previous Message PG Bug reporting form 2018-05-25 16:17:18 BUG #15208: COALESCE with CTE returns NULL