Window function fails with many-to-one relationship
Hello guys,
I'm trying to use a window function to sum some values with a many-to-one relations but it's failing with this error
You cannot use the window function 'sum' in this context.
With the following query
The schema is as follows:
And this is the query I'm trying to execute
Hopefully I was clear enough and I appreciate your help in advance.3 Replies
I ran out of characters lol...
This works just fine if the relation is one-to-one but with many-to-one it fails. With one-to-one the query it yields is this one:
I noticed that with many-to-one it adds a COALESCE and a JSON_ARRAYAGG to the query.
This is a sample of my real code which is a query a lot bigger, I reduced it to the minimum I could.
Relational Query API is a bit limited for now, so not all such functions may work in extra field
I ended up using a CTE and a subquery