In fact, the code write after the SQL SELECT instruction is executed in the source language
That is to say in your SQL server database, so you have to have the SQL Server syntax.
If you want to use QlikView Syntax, you must use a LOAD without FROM clause before the SQL SELECT
the easier way to do it is to use the wizard : Go in the Script section, add use the option "preceding load". Then select data again in your database.
You will see two level :
The Script will first execute the SQL Select instruction (so you can use the SQL Server SQL syntax here). Then the Load Statement will be executed and you will be able to use QlikView functions upon field loaded in SQL Select.
Hope it helps