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
I think this may be similar to #192. Of course, one can always argue about what is the correct style. :) This was done on the website (v4.3), default options (only first box checked).
WITH op AS (
SELECT
extract(year FROM created_date) AS year,
extract(month FROM created_date) AS month,
count(ticket) AS num
FROM
tickets
WHERE
product = 'x'
GROUP BY
year,
month
),
cl AS (
SELECT
extract(year FROM closed_date) AS year,
extract(month FROM closed_date) AS month,
count(ticket) AS num
FROM
tickets
WHERE
product = 'x'
AND closed_date IS NOT NULL
GROUP BY
year,
month
),
tot AS (
SELECT
op.year,
op.month,
op.num AS opened,
coalesce(cl.num, 0) AS closed,
op.num - coalesce(cl.num, 0) AS diff
FROM
op
LEFT JOIN cl ON (op.year = cl.year
AND op.month = cl.month))
-- why is this SELECT indented? shouldn't it be on the same level as the WITH?
SELECT
year,
month,
opened,
closed,
diff,
sum(diff) OVER (ORDER BY year, month) AS total
FROM
tot
ORDER BY
year,
month;
So this may or may not be a bug, but it seems to me it should look like (at a high level):
WITH op AS (
...
),
cl AS (
...
),
tot AS (
...
) -- error starts here, if this had gone back to col 1 like the others, then the select would have been in col 1 too (i think)
SELECT ...
FROM tot
ORDER BY year, month
;
So it seems like the last close paren of the last CTE clause is where the problem is. More experimenting shows that it's good 1 or 2 CTE clauses (with op or op+cl above), it's when i add the 3rd (tot) that things go wrong. I can add a 4th and get the same error, but it doesn't get worse, if that helps.
Here's what it looks like with 2 windows, which I believe is correct:
WITH op AS (
SELECT
extract(year FROM created_date) AS year,
extract(month FROM created_date) AS month,
count(ticket) AS num
FROM
tickets
WHERE
product = 'x'
GROUP BY
year,
month
),
cl AS (
SELECT
extract(year FROM closed_date) AS year,
extract(month FROM closed_date) AS month,
count(ticket) AS num
FROM
tickets
WHERE
product = 'x'
AND closed_date IS NOT NULL
GROUP BY
year,
month
)
SELECT
year,
month,
opened,
closed,
diff,
sum(diff) OVER (ORDER BY year, month) AS total
FROM
tot
ORDER BY
year,
month
The text was updated successfully, but these errors were encountered:
I think this may be similar to #192. Of course, one can always argue about what is the correct style. :) This was done on the website (v4.3), default options (only first box checked).
So this may or may not be a bug, but it seems to me it should look like (at a high level):
So it seems like the last close paren of the last CTE clause is where the problem is. More experimenting shows that it's good 1 or 2 CTE clauses (with op or op+cl above), it's when i add the 3rd (tot) that things go wrong. I can add a 4th and get the same error, but it doesn't get worse, if that helps.
Here's what it looks like with 2 windows, which I believe is correct:
The text was updated successfully, but these errors were encountered: