Crosstab function in sql query editor is not recognised

Hello there ! :slight_smile:

To give a bit of context:
I would like to reuse output of a pivot table, so that I can perform new operations on it.
–> My pivot table using the UI is outputting:

Screenshot 2020-10-06 at 12.23.55

I have found this:
Pivot the result of a SQL query ,
telling me that I cannot do it with the UI, but need to use corosstab function in my SQL query (I’m using Postgre)

So I’ve designed this query:

But I looks like the cross tab function is not being recognised :
Look here how the query that is supposed to be passed as text inside is not recognised as such :

Screenshot 2020-10-06 at 12.29.51

And I get a syntax error:
ERROR: syntax error at or near “‘year’” Position: 701

Thanks for you help :slight_smile:

Hi @MichaelU
I’m not sure I understand what you’re trying to do, but try putting the crosstab text query on a single line.
And you need to use "year" instead of year - it’s a reserved word https://www.postgresql.org/docs/current/sql-keywords-appendix.html

Thank you @flamber, putting the text query on one line helped me here !
And thanks for noticing the ugly use of year :wink: