Re: SQL Order Question

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: operationsengineer1(at)yahoo(dot)com
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: SQL Order Question
Date: 2006-05-04 19:40:11
Message-ID: 20060504194011.GA15993@wolff.to
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, May 04, 2006 at 11:33:33 -0700,
operationsengineer1(at)yahoo(dot)com wrote:
> hi all,
>
> i want to order contract numbers id ascending order,
> with the exception of 'BTS' that I want to display
> first. the contract numbers are numeric and 'BTS' is
> text. the numeric values come first when i sort in
> asc order - as expected. how can i get BTS (id = 0)
> to come up as the first value in my query?

You can first order by column <> 'BTS'. Ordering by the numeric values is
trickier, but you should be able to have a case statement with a regular
expression that checks for valid numbers and in that case return the string
casted to numeric and for the invalid case return a constant numeric.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Richard Broersma Jr 2006-05-04 19:40:21 Re: SQL Order Question
Previous Message operationsengineer1 2006-05-04 19:34:15 Re: SQL Order Question