Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: get # matches on OR statements
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