ORDER records based on parameters in IN clause
От | Riya Verghese |
---|---|
Тема | ORDER records based on parameters in IN clause |
Дата | |
Msg-id | BBA4F47BB0CEDD4D8ADD2FE21E2823673110A4@dhost002-37.dex002.intermedia.net обсуждение исходный текст |
Ответы |
Re: ORDER records based on parameters in IN clause
Re: ORDER records based on parameters in IN clause Re: ORDER records based on parameters in IN clause Re: ORDER records based on parameters in IN clause |
Список | pgsql-sql |
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">I have a stmt where the outer-query is limited by the results of the inner query. I would like the outerquery to return records in the same order as the values provided in the IN clause (returned form the inner query). </span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">The inner_query is returning id’s ordered by count(id) , i.e by most common occurrence.</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">In essence,</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">when I say </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">select * from table where id IN (2003,1342,799, 1450) </span></font><p class="MsoNormal"><font face="Arial"size="2"><span style="font-size:10.0pt; font-family:Arial">I would like the records to be ordered as 2003, 1342, 799, 1450. The outer query has no knowledge ofthe count(id) that the inner_query is ordering by.</span></font><p class="MsoNormal"><font face="Arial" size="2"><spanstyle="font-size:10.0pt; font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">Currently postgres returns it in this order (1450,1342,799,2003)</span></font><p class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">Any help would be appreciated.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">Thanks,</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; font-family:Arial">R. Verghese</span></font></div>
В списке pgsql-sql по дате отправления: