Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: get # matches on OR statements

Re: get # matches on OR statements

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Mon, 13 Sep 1999 07:16:54 +0100
Message-ID: <937203848.17189.0.nnrp-07.9e984b29@news.demon.co.uk>


Try

SELECT * from a_table
where col1 = 'a' OR col2 = 'b' OR col3 = 'c' order by decode(col1,'a',1,0) +

            decode(col2,'b',1,0) +
            decode(col3,'c',1,0)

--

Jonathan Lewis
Yet another Oracle-related web site: http://www.jlcomp.demon.co.uk

nwsread_at_cloudband.com wrote in message <37dc3b65_at_glitch.nildram.co.uk>...
> Givin the following sql query. Is there a way
>through trigger or procedural language to order the rows
>returned by number of true or's(1-3) in this case for
>returned rows.
>
> SELECT * from a_table where col1 = 'a' OR col2 = 'b' OR
>col3 = 'c';
>
> Basically i want to make these type of queries and order
>the results by how many columns match their search strings. e.g.
>all three cols matching being in front of rows where only one
>columnn matches it's search string.
>
>
>
Received on Mon Sep 13 1999 - 01:16:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US