I am following the doc1 and doc2 but I am getting an error.
I was under the impression from the documentation that it is doable in pure sql. What am I doing wrong?

I know how to do this in python using dataframe API and I am not looking for that solution.
Thank you in advance.