Riya Verghese wrote:
select * from table where id IN (2003,1342,799, 1450)
I would like the records to be ordered as 2003, 1342, 799, 1450. The
outer query has no knowledge of the count(id) that the inner_query is
ordering by.
I think this is the real problem: outer query must know count(id) to
order by count(id). You can use it in the outer with something like this:
SELECT
table.*
FROM
table
JOIN (SELECT id, count(id) AS count FROM... your subquery) AS x
ORDER BY
x.count
Bye.
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match