ORDER BY and null values
ORDER BY and null values
От:
Paulo Jan <admin@digital.ddnet.es>
Дата:
Hi all: Sorry if this has been asked before. Just did a quick search in the archives and didn't find anything that was 100% relevant. I have a table with a date field, where some of the rows are empty (with NULL values) and some aren't. I need to make a "SELECT ORDER BY date DESC" but my customer wants the rows with empty values to appear at the bottom of the result set, instead of at the top. Is this possible? Paulo Jan. DDnet.
Re: ORDER BY and null values
От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Wed, Jul 10, 2002 at 14:04:32 +0200, Paulo Jan wrote: > Hi all: > > Sorry if this has been asked before. Just did a quick search in the > archives and didn't find anything that was 100% relevant. > I have a table with a date field, where some of the rows are empty > (with NULL values) and some aren't. I need to make a "SELECT > ORDER BY date DESC" but my customer wants the rows with empty values to > appear at the bottom of the result set, instead of at the top. Is this > possible? You can use expressions in order by, so it is possible to do. One option is to use coalesce if there is something safe to map nulls to always get the right ordering. There are other ways to make this work if you don't have a bound on the dates.