Re: ORDER records based on parameters in IN clause

Поиск
Список
Период
Сортировка
От Zac
Тема Re: ORDER records based on parameters in IN clause
Дата
Msg-id d9u33p$1ao3$1@news.hub.org
обсуждение исходный текст
Ответ на ORDER records based on parameters in IN clause  ("Riya Verghese" <riya.verghese@admissioncorp.com>)
Ответы Re: ORDER records based on parameters in IN clause
Список 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 по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: ORDER records based on parameters in IN clause
Следующее
От: Zac
Дата:
Сообщение: Re: ORDER records based on parameters in IN clause