You need to sign in to do that
Don't have an account?

Vf Variables passed to order by clause in sql queries
Hi All,
I am trying to pass a picklist value into a sql query "order by" clause
However i am not able to use the syntax :
:<variable name> in order by
Could you please suggest me a solution to this
Regards
Rajat.
Hi Rajat,
In SOQL we cannot use variable after an ORDER BY clause the solution is to use Dynamic SOQL which provides you the flexibility of creating a query string and execute. Please have a look at the code below .if change the variable field to some another field name the n the selection will be order by that field.
try the above code as your requirement ,feel free for further clarifications.