BUG #15208: COALESCE with CTE returns NULL
От | PG Bug reporting form |
---|---|
Тема | BUG #15208: COALESCE with CTE returns NULL |
Дата | |
Msg-id | 152726503844.26748.4906459255150532845@wrigleys.postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #15208: COALESCE with CTE returns NULL
Re: BUG #15208: COALESCE with CTE returns NULL |
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 15208 Logged by: Rick Gabriel Email address: klaxian@gmail.com PostgreSQL version: 10.4 Operating system: Ubuntu Linux 16.04 Description: When using COALESCE with an aggregate subquery to a CTE, NULL is returned instead of the first non-null value in the argument list. Proof-of-concept examples are below. I would expect COALESCE to return 0 in these cases. Am I missing something? Thanks. WITH test_cte AS (SELECT 1 AS id, 2 AS qty) SELECT COALESCE(SUM(qty), 0) FROM test_cte WHERE id=2; WITH test_cte AS (SELECT 1 AS id, 2 AS qty) SELECT COALESCE((SELECT SUM(qty) FROM test_cte WHERE id=2), 0);
В списке pgsql-bugs по дате отправления: