From: | "Riya Verghese" <riya(dot)verghese(at)admissioncorp(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | ORDER records based on parameters in IN clause |
Date: | 2005-06-27 16:15:15 |
Message-ID: | BBA4F47BB0CEDD4D8ADD2FE21E2823673110A4@dhost002-37.dex002.intermedia.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Roy Souther | 2005-06-27 17:16:58 | How can I simply substatue a value in a query? |
Previous Message | Markus Bertheau ☭ | 2005-06-27 15:34:09 | SELECT * FROM foo OFFSET -1 LIMIT 1 |