Sorting Using Results of Subquery? -
03-29-2010
, 04:46 PM
All,
I have a query I need to ORDER BY by either;
a) The result of another query (always a single text string, e.g;
"TBL_Timers.TimerPos DESC".
b) a variable containing that result.
Is there any way for me to do this? (I'm calling the query from VB
via a DataGridView table adaper, so I don't think I can string the SQL
together in a module.)
I've gotten as far as verifying I can see my variable (SortStr) in a
query result set (just to prove to myself I'm building it correctly).
It comes back as "TBL_Timers.TimerPos DESC" w/o quotes.
But I can't seem to figure out how to insert (npi) it into my SQL
code.
I thought I could use
SELECT TBL_Timers.TimerID, TBL_Timers.TimerPos
FROM TBL_Timers order by SortStr();
But the results don't sort.
Any suggestions?
Am I going about this wrong?
Thanks, |