4 ms·
This actually answers the question, although I would imagine the ORDER BY handling will look pretty messy (CASE statement perhaps?). And I don't know what it w
by ad_hominem 12y ago
This actually answers the question, although I would imagine the ORDER BY handling will look pretty messy (CASE statement perhaps?).
And I don't know what it would look like if the requirements changed to allow ordering by multiple columns with different possible sort directions... that might get back into dynamic SQL using a RETURN QUERY EXECUTE type of thing, which is basically using a query builder in your query language.
- babuskov 12y agoMost SQL engines support ordering by column number. select c1, c2, c3, ... order by 2; would order by "c2"