Re: [SQL] ORDER BY what?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
Cc: David Olbersen <dave(at)slickness(dot)org>, pgsql sql Mailing List <pgsql-sql(at)postgresql(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: [SQL] ORDER BY what?
Date: 2001-06-13 13:16:56
Message-ID: 20010613081656.A20924@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Tue, Jun 12, 2001 at 03:53:22PM +0300,
Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> wrote:
> On Mar 12 Jun 2001 02:23, David Olbersen wrote:
> > On Mon, 11 Jun 2001, Martín Marqués wrote:
> > > My question is: "How can I write an ORDER BY statment so that it's
> > > ordered by the amount of matches it gets?"
> >
> > Your question is a bit unclear, what is "it"?
> > Specifically, what are the "it's" that are to be ordered, and which "it"
> > gets matches?
>
> 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2001-06-13 13:21:15 Re: Exploring sequences (sequence context within a tran saction)
Previous Message Fabrizio Mazzoni 2001-06-13 13:07:32 sum of row values..

Browse pgsql-sql by date

  From Date Subject
Next Message DHSC Webmaster 2001-06-13 13:32:24 performance issues
Previous Message David BOURIAUD 2001-06-13 09:17:14 Help on a sql querry.