Re: BUG #18430: syntax error when using aggregate function in where clause of subquery
В списке pgsql-bugs по дате отправления:
| От | Laurenz Albe |
|---|---|
| Тема | Re: BUG #18430: syntax error when using aggregate function in where clause of subquery |
| Дата | |
| Msg-id | cd61a2c86437acce0624280e3998bcacd5f48cc9.camel@cybertec.at обсуждение исходный текст |
| Ответ на | BUG #18430: syntax error when using aggregate function in where clause of subquery (PG Bug reporting form <noreply@postgresql.org>) |
| Ответы |
Re: BUG #18430: syntax error when using aggregate function in where clause of subquery
|
| Список | pgsql-bugs |
On Fri, 2024-04-12 at 17:14 +0000, PG Bug reporting form wrote:
> SELECT
> city,
> (SELECT count(*) FROM delivery WHERE driver_id IN array_agg(driver.id))
> AS deliveries
> FROM driver
> GROUP BY city
> ;
>
> This produces:
>
> ERROR: syntax error at or near "array_agg"
> LINE 3: ...(SELECT count(*) FROM delivery WHERE driver_id IN array_agg(...
This not a bug, but bad syntax.
Write
SELECT city,
(SELECT count(*)
FROM delivery
WHERE driver_id = ANY (drivers)) AS deliveries
FROM (SELECT city,
array_agg(driver.id) AS drivers
FROM driver
GROUP BY city) AS q;
Yours,
Laurenz Albe
В списке pgsql-bugs по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера