pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gregor Rot <zara4tustra@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: order of results
Date: Sat, 03 Apr 2004 17:08:34 +0200
Message-ID: <QrAbc.238$37.31493@news.siol.net> (raw)
In-Reply-To: <20040326215303.GC21119@wolff.to>
References: <S2B8c.6954$%x4.923499@news.siol.net>
	<20040326215303.GC21119@wolff.to>

Bruno Wolff III wrote:
> On Thu, Mar 25, 2004 at 14:23:00 +0100,
>   Gregor Rot <zara4tustra@yahoo.com> wrote:
> 
>>Hi,
>>
>>i have a table called "people" (name:varchar, lastname:varchar).
>>
>>i do a select on it:
>>
>>select * from people where name like '%n1%' or lastname like '%l1%'.
>>
>>i would like the results in this order:
>>
>>first the results that satisfy only the (name like '%n1%') condition, 
>>then the ones that satisfy only the (lastname like '%l1%') condition and 
>>last the results that satisfy both conditions.
>>
>>Is this possible in only one SQL?
>>(note that the search conditions n1 and l1 differ from search to search.
> 
> 
> Yes. You can order by true/false results from conditions to get the
> results in the desired order.

Thank you - sorry, but how do you do that?

Tnx,
Gregor



view thread (4+ messages)  latest in thread

Message-ID: <QrAbc.238$37.31493@news.siol.net>
Permalink:  ../QrAbc.238$37.31493@news.siol.net/
Also on:    postgresql.org/message-id/QrAbc.238$37.31493@news.siol.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: zara4tustra@yahoo.com
  Subject: Re: order of results
  In-Reply-To: <QrAbc.238$37.31493@news.siol.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox