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'm trying to execute a window function but I'm getting this error:
near "(": syntax error (code 1): , while compiling: WITH cte AS (
SELECT *,
COUNT(*) OVER (PARTITION BY grp) count,
ROW_NUMBER() OVER (PARTITION BY grp ORDER BY date) rn
FROM (
SELECT *, SUM(flag) OVER (ORDER BY date) grp
FROM (
SELECT *, (type <> LAG(type, 1, '') OVER (ORDER BY date)) flag
FROM chatMessages WHERE chatID = 'alternateChat'
)
)
)
SELECT id, type, date, message,
CASE WHEN type = 'groupedMsgs' THEN count END numConsecutiveItems
FROM cte
WHERE numConsecutiveItems IS NULL OR rn = 1;
And the operation that uses window functions is this:
WITH cte AS (
SELECT*,
COUNT(*) OVER (PARTITION BY grp) count,
ROW_NUMBER() OVER (PARTITION BY grp ORDER BYdate) rn
FROM (
SELECT*, SUM(flag) OVER (ORDER BYdate) grp
FROM (
SELECT*, (type <> LAG(type, 1, '') OVER (ORDER BYdate)) flag
FROM chatMessages WHERE chatID ='alternateChat'
)
)
)
SELECT id, type, date, message,
CASE WHEN type ='groupedMsgs' THEN count END numConsecutiveItems
FROM cte
WHERE numConsecutiveItems IS NULLOR rn =1;
I've created a sample app that reproduces the problem here, and the code can be viewed here. For good measure I reproduced the exact same operation using this fiddle and you can see that it works there. So I don't understand why it's not working using this plugin. The README makes it clear that window functions were added since #837 so I expect this operation to work.
The full context of what I want to achieve is explained in this stack overflow post, but nevertheless the summary is that I want to group and count consecutive rows based on some matching and ranking criteria. It turns out that window functions can be used to do exactly what I want, but they're not working as shown above. Am I doing something wrong?
The text was updated successfully, but these errors were encountered:
I'm trying to execute a window function but I'm getting this error:
The setup is:
And the operation that uses window functions is this:
I've created a sample app that reproduces the problem here, and the code can be viewed here. For good measure I reproduced the exact same operation using this fiddle and you can see that it works there. So I don't understand why it's not working using this plugin. The README makes it clear that window functions were added since #837 so I expect this operation to work.
The full context of what I want to achieve is explained in this stack overflow post, but nevertheless the summary is that I want to group and count consecutive rows based on some matching and ranking criteria. It turns out that window functions can be used to do exactly what I want, but they're not working as shown above. Am I doing something wrong?
The text was updated successfully, but these errors were encountered: