title: Where clause based on priority
body: <p>Consider Following table named A:</p>
  
  <pre><code>  State City Rank
     S     C    1
    AB     C1   2
     *     C2   3
  </code></pre>
  
  <p>I want to select all columns such that</p>
  
  <ol>
  <li>If State is AB return all such rows</li>
  <li>If condition 1 is not met return all rows with state *. If condition 1 is met don't look on to this condition</li>
  </ol>
  
  <p>As per above example I should get row 2.  I tried several things like </p>
  
  <pre><code>select state
       case when a.state = 'AB' then 1
             when a.state = '*'  then 2
        end as priority   from A  where state in  ('AB','*')  order by priority
  </code></pre>
  
  <p>But above query returns more than one rows. I want exact one row which matches above condition.</p>
  
  <p>Please help</p>
  
  <p>EDIT1:</p>
  
  <p>I want to avoid sub queries due to performance issues. </p>