SQLite Forum

possible to use output of a SELECT-query for ordering?
Login
Hello,

is it possible to order a table by using the result of another query?

Example:
<code>
CREATE TABLE a (b INTEGER, c INTEGER);
INSERT INTO a VALUES (1,3),(2,7),(3,2),(5,1),(8,9),(9,3);
SELECT * FROM a ORDER BY (SELECT 'c'); -- the constant 'c' is just for demonstration; this should eventually be a select from a different table
</code>

The [manual](https://sqlite.org/lang_select.html) says

> Otherwise, if the ORDER BY expression is any other expression, it is evaluated and the returned value used to order the output rows. If the SELECT statement is a simple SELECT, then an ORDER BY may contain any arbitrary expressions.

To me it sounds as if it was possible, by it's not working for me.