I have a stmt where the outer-query is limited by the results of the inner query. I would like the outer query to return records in the same order as the values provided in the IN clause (returned form the inner query).
The inner_query is returning id’s ordered by count(id) , i.e by most common occurrence.
In essence,
when I say
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.
Currently postgres returns it in this order (1450,1342,799,2003)
Any help would be appreciated.
Thanks,
R. Verghese