Re: ORDER records based on parameters in IN clause - Mailing list pgsql-sql

From Zac
Subject Re: ORDER records based on parameters in IN clause
Date
Msg-id d9u33p$1ao3$1@news.hub.org
Whole thread Raw
In response to ORDER records based on parameters in IN clause  ("Riya Verghese" <riya.verghese@admissioncorp.com>)
Responses Re: ORDER records based on parameters in IN clause  (Zac <zaccheob@inwind.it>)
List pgsql-sql
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:

SELECTtable.*
FROMtableJOIN (SELECT id, count(id) AS count FROM... your subquery) AS x
ORDER BYx.count

Bye.


pgsql-sql by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: ORDER records based on parameters in IN clause
Next
From: Zac
Date:
Subject: Re: ORDER records based on parameters in IN clause