title: How to prioritize in OR condition in SQL Server
body: <p>I have a simple query where I want to search for a value in a column, and if no match is found then I want to discard that where condition and select any random value from that column.</p>
  
  <p>I have tried to achieve this using <code>OR</code> condition, using case, but to no avail</p>
  
  <pre><code>select top 10 * 
  from tblRFCWorkload 
  where (f1 ='mbb' or f1 = f1)
  </code></pre>
  
  <p>In the above query I want the result table to have all rows with 'mbb', if 'mbb' is not found then give any value instead of mbb. But instead it returns only two rows with mbb even though there are 10 matching rows</p>
  
  <pre><code>select top 10 *
  from tblRFCWorkload
  where 1 = case when f1 = 'mbb' then 1 else 1 end
  </code></pre>
  
  <p>This query also returns the same result as the 1st query</p>
  
  <p>If I change it to </p>
  
  <pre><code>select top 10 *
  from tblRFCWorkload
  where 1 = case when f1 = 'mbb' then 1 else 0 end
  </code></pre>
  
  <p>then it only rows having the mbb value.</p>
  
  <p>Need similar thing with between clause... search for one range if no results found then search for second range... how do I do that???</p>