pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Martín Marqués <martin@bugs.unl.edu.ar>
Cc: David Olbersen <dave@slickness.org>
Cc: pgsql sql Mailing List <pgsql-sql@postgresql.org>
Cc: pgsql-general@postgresql.org
Subject: Re: [SQL] ORDER BY what?
Date: Wed, 13 Jun 2001 09:57:02 -0500
Message-ID: <20010613095702.B21307@wolff.to> (raw)
In-Reply-To: <01061311265400.08685@bugs>
References: <Pine.LNX.4.31.0106111622110.2923-100000@bubbles.electricutopia.net>
	<01061215532200.04895@bugs>
	<20010613081656.A20924@wolff.to>
	<01061311265400.08685@bugs>

On Wed, Jun 13, 2001 at 11:26:54AM +0300,
  Martín Marqués <martin@bugs.unl.edu.ar> wrote:
> On Mié 13 Jun 2001 16:16, Bruno Wolff III wrote:
> > On Tue, Jun 12, 2001 at 03:53:22PM +0300,
> >
> > >
> > > OK, let me give an example:
> > >
> > > select * from tab1 where col1 like '%word%' or col2 like '%word%' and
> > > col3 like '%word%'
> > >
> > > and I want to order by the amopunt of matches that a matching register
> > > has. Something like, if it matches all the ORs, then it should go first,
> > > and if it matches only one of the ORs it should go last.
> > > Or maybe even have several words trying to match one of the columns.
> >
> > You could do this by computing a value based on the number of parts
> > that matched and order by it.
> 
> Could you give me a hint on this? Do I have to use PLSQL? Triggers? Something 
> else?
> 
> Thanks for the responce.

You can use the case statement to check logical tests and return different
values depending on which ones are true. This expression can be used in
the order by clause.



view thread (9+ messages)  latest in thread

Message-ID: <20010613095702.B21307@wolff.to>
Permalink:  ../20010613095702.B21307@wolff.to/
Also on:    postgresql.org/message-id/20010613095702.B21307@wolff.to

 · 

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: bruno@wolff.to, martin@bugs.unl.edu.ar, dave@slickness.org, pgsql-general@postgresql.org
  Subject: Re: [SQL] ORDER BY what?
  In-Reply-To: <20010613095702.B21307@wolff.to>

* 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