Hello Richard,
In Advanced Query (SQL), you can pass an Inline Parameter with part of the SQL.
There is an example on how to do this for dynamic sort in SQL here (It is the same thing for version 10): https://www.outsystems.com/help/servicestudio/9.1/index.htm#t=Using_Data%2FSQL_Parameters.htm
So, you just need to set the Expand Inline property of your attribute to YES (in your code, it is set to NO).
Cheers.