Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-03-31 : 09:44:25
|
mark writes "Hello, SQL Guru.
What's the most efficient way to rank the results in a multiple condition OR query, i.e., how do I get the Recordset ORDERed BY the number of conditions satisfied?
SELECT * FROM Table WHERE ConditionA = true OR ConditionB = true OR ConditionC = true ORDER BY [Number of Conditions Satisfied] DESC
Do I use something like:
ORDER BY (SELECT * FROM Table WHERE ConditionA = true AND ConditionB = true AND ConditionC = true), (SELECT * FROM Table WHERE ConditionA = true AND ConditionB = true), (SELECT * FROM Table WHERE ConditionA = true AND ConditionC = true), (SELECT * FROM Table ConditionB = true AND ConditionC = true), (SELECT * FROM Table WHERE ConditionA = true), (SELECT * FROM Table WHERE ConditionB = true), (SELECT * FROM Table WHERE ConditionC = true),
Probably not that way, but maybe you get the picture? No?
TIA, mark" |
|
|
|
|
|