Search Postgresql Archives

Re: ORDER BY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 14 nov 2006, at 23.03, MicroUser wrote:
I need sorted result but the way like this:

0 | Anna
3 | Fernando
2 | Link
1 | Other

Record '1 | Other' must by at the end of query result.

How I can get it?

Something along these lines might work.

select * from table
where <field> !=1
order desc by <field>

union

select * from table
where <field>=1;

or if the last record is always the same, hard code the values in the sql instead of querying the table, which will save a few milliseconds :-)

If it is the "other" and not the "1" that you want last, change the first query where clause to where <field> != 'Other' & similarly change the second one.


Cheers,

 Brent Wood


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux