You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from invoices
group billing_city (
aggregate{
sum_c = (sum(customer_id)) + (sum(customer_id))
}
)
generates sql query:
SELECT
billing_city,
COALESCE(SUM(customer_id), 0) + COALESCE(SUM(customer_id), 0) AS sum_c
FROM
invoices
GROUP BY
billing_city
but after adding a filter at the end:
from invoices
group billing_city (
aggregate{
sum_c = (sum(customer_id)) + (sum(customer_id))
}
)
filter sum_c>0
then the resulting query does not compile, as the group by should be done in table_0 inner query, right?
WITH table_0 AS (
SELECT
billing_city,
COALESCE(SUM(customer_id), 0) AS _expr_0,
COALESCE(SUM(customer_id), 0) AS _expr_1
FROM
invoices
)
SELECT
billing_city,
_expr_0 + _expr_1 AS sum_c
FROM
table_0
GROUP BY
billing_city
HAVING
_expr_0 + _expr_1 > 0
I noticed that this only happens when you aggregate by combining two different aggregation functions.
PRQL input
from invoices
group billing_city (
aggregate{
sum_c =(sum(customer_id))+(sum(customer_id))})filter sum_c>0
SQL output
WITH table_0 AS (
SELECT
billing_city,
COALESCE(SUM(customer_id), 0) AS _expr_0,
COALESCE(SUM(customer_id), 0) AS _expr_1
FROM
invoices
)
SELECT
billing_city,
_expr_0 + _expr_1 AS sum_c
FROM
table_0
GROUP BY
billing_city
HAVING
_expr_0 + _expr_1 >0
Expected SQL output
SELECT
billing_city,
COALESCE(SUM(customer_id), 0) + COALESCE(SUM(customer_id), 0),
FROM
invoices
GROUP BY
billing_city
HAVING
COALESCE(SUM(customer_id), 0) + COALESCE(SUM(customer_id), 0) >0
MVCE confirmation
Minimal example
New issue
Anything else?
No response
The text was updated successfully, but these errors were encountered:
What happened?
PRQL compiler version:0.13.3
This query:
generates sql query:
but after adding a filter at the end:
then the resulting query does not compile, as the group by should be done in table_0 inner query, right?
I noticed that this only happens when you aggregate by combining two different aggregation functions.
PRQL input
SQL output
Expected SQL output
MVCE confirmation
Anything else?
No response
The text was updated successfully, but these errors were encountered: