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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How to add a weight factor to a query?

Re: How to add a weight factor to a query?

From: Daniel A. Morgan <dmorgan_at_exesolutions.com>
Date: Wed, 24 Jan 2001 20:40:18 -0800
Message-ID: <3A6FAE32.3AEF8B41@exesolutions.com>

> How do I add a weight factor to a query? For example, take the
> following query:
>
> SELECT table.field1, table.field2, table.field3
> FROM table
> WHERE field1 = 'value1'
> AND field2 = value2
> OR field3 = value3
>
> What I would like to do now is give each test a factor of importance.
> So (field1 = 'value1') should be the most important, let's say 60%, the
> other two should be of importance for 20% each.
>
> Can anybody help me with this? Thanks very much in advance for your
> time and effort!

The only way I know to do this is to create a view or snapshot in which you display the data with the weight factor calculated and then query from that object. You could use a decode to create the values for the weight-value field.

Obviously the SQL for the view or snapshot could be incorporated into a SQL query but approaching it in this way (with the view) will make it less complicated to construct or (with the snapshot) run substantially faster.

Hope this helps.

Daniel A. Morgan Received on Wed Jan 24 2001 - 22:40:18 CST

Original text of this message

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