If you are particular about using Custom SQL in your Lookup_Ext then you can follow the below code. I have tested it and it shall work.
You need to make sure that Custom SQL selects all the columns you need in the Lookup as well as whatever you put in the WHERE clause.
Regards,
Ansari