Re: ORDER BY TIMESTAMP_column ASC, NULL first - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: ORDER BY TIMESTAMP_column ASC, NULL first
Date
Msg-id 20040603173101.GA5022@wolff.to
Whole thread Raw
In response to ORDER BY TIMESTAMP_column ASC, NULL first  (Fredrik Wendt <fredrik@csbnet.se>)
List pgsql-sql
On Thu, Feb 12, 2004 at 11:06:26 +0100, Fredrik Wendt <fredrik@csbnet.se> wrote:
> 
> The query to use would be,
>     
> SELECT ip.id FROM IPv4Address ip ORDER BY assignedAt ASC LIMIT 1;
> 
> with the exception that this returns rows with NULL at the end, instead
> of at the beginning which is what I'd like.
> 
> How do achieve this with one query? I'm using Postgres 7.4.

SELECT ip.id FROM IPv4Address ip ORDER BY assignedAt IS NULL, assignedAt ASC LIMIT 1;


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Reference with condition on other table column?
Next
From: Joseph Turner
Date:
Subject: Selecting "sample" data from large tables.