From: | <operationsengineer1(at)yahoo(dot)com> |
---|---|
To: | George Weaver <gweaver(at)shaw(dot)ca>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: SQL Order Question |
Date: | 2006-05-04 20:21:15 |
Message-ID: | 20060504202115.60111.qmail@web33312.mail.mud.yahoo.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
> You might be able to achieve what you want using the
> fact that Order By
> sorts false before true, so:
>
> Order By not(contractid = 'BTS'), contractid ASC
>
> Regards,
> George
>
> ----- Original Message -----
> From: <operationsengineer1(at)yahoo(dot)com>
> To: <pgsql-novice(at)postgresql(dot)org>
> Sent: Thursday, May 04, 2006 1:33 PM
> Subject: [NOVICE] SQL Order Question
>
>
> > 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?
> >
> > tia...
George, you are on the money... this does it:
SELECT contract_id, contract_number FROM t_contract
ORDER BY not(contract_number = 'BTS'), contract_number
ASC
thanks to all who helped.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2006-05-04 20:21:26 | Re: SELECT FOR UPDATE - release lock? |
Previous Message | Bruno Wolff III | 2006-05-04 20:19:51 | Re: SQL Order Question |