Search Postgresql Archives

Re: Overriding natural order of query results for a subset

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

 



Michael Nolan <htfoot@xxxxxxxxx> writes:
> You probably need some kind order by case when .... else .... end clause,
> where the else clause deals with the non-VIPs, probably negating the need
> for a nulls last clause.

The idiomatic way to do this, assuming that you create an "is_vip bool"
field or some other way to identify VIPs accurately, is

	ORDER BY is_vip DESC, last_name, first_name

relying on the fact that bool TRUE > bool FALSE.

			regards, tom lane





[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 Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux