title: SQL order by with case not ordering correctly
body: <p>I have this simple SQL Select query:</p>
  
  <pre><code>SELECT part_number, bin_location FROM list ORDER BY bin_location
  </code></pre>
  
  <p>This will give me a result like this:</p>
  
  <pre><code>part_number       bin_location
  Alaska wine           A1
  German water          A2
  London whisky         A3
  German wine           A4
  London water          B1
  German wine           B2
  London whisky         B3
  German wine           C1
  London whisky         C2
  Water Green Wine      C3
  Pure Water            D1
  Orange whisky         D2
  Ireland Moat          D3
  French wine           XX
  Italy water           XX
  Water Green Wine      XX
  Pure Water            XX
  Orange whisky         XX
  Ireland Moat          XX
  French wine           XX
  Italy water           XX
  </code></pre>
  
  <p>Now what i'm trying to do is order by bin_location and once bin_location equals xx order by part_number.</p>
  
  <p>This is the query I am using to do this:</p>
  
  <pre><code>SELECT part_number,bin_location 
  FROM list 
  ORDER BY case when bin_location = 'xx' then part_number end 
  </code></pre>
  
  <p>This is the result I get:</p>
  
  <pre><code>part_number       bin_location
  Alaska wine           A1
  German water          A2
  London whisky         A3
  German wine           C1
  London water          A4
  German wine           B2
  London whisky         B3
  German wine           A4
  London whisky         C2
  Water Green Wine      C3
  Pure Water            D1
  Orange whisky         D2
  Ireland Moat          D3
  French wine           XX
  French water          XX
  Ireland Moat          xx
  Italy water           XX
  Orange whisky         XX
  Pure Water            XX
  Water Green Wine      XX
  </code></pre>
  
  <p>As you can see after the xx clause is met it puts the part_number in order, but before this the bin location is not.</p>
  
  <p>How can I fix this?</p>
  
  <p>Thanks in advance.</p>