query result that depends on the count of matching field contents in one record

Ralf Sander ralf at end-if.de
Sat May 7 00:28:10 CDT 2005


Hi,

I want to create a search where I get a result that depends on the 
count matching field contents in one record. But I can't get it. May 
be, I am thinking in the wrong direction.
Lets assume, I have a table with 4 fields (vshort). Now I want to get 
all records where more than 2 field matches a condition.

Example:

if the code "field1 Between 1 and 5" would return 0 or 1, I could add 
all results:

  SELECT * FROM TABLE1  WHERE (  (  field1=2 ) + (  field2=7 ) + (  
field3=10 )  + (  field4=1 )   ) >2

or

  SELECT * FROM TABLE1  WHERE (  (  field1 BETWEEN 1 AND 5 ) + (  field2 
BETWEEN 1 AND 7 ) + (  field3 BETWEEN 2 AND 4 )  + (  field4 BETWEEN 1 
AND 2 )   ) >2

Any solution for that?


Thanks
Ralf




More information about the Valentina mailing list