title: SQL Server 2005: Order with NULL values at the end
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2498240/case-order-by-using-null">Case Order by using Null</a>  </p>
  </blockquote>
  
  
  
  <p>I'm looking to get a list of records ordered by an "ordernum" field.  The ordernum field is an int field.  This field starts as NULL until set by a user.  I would like the NULL entries to appear at the end of the list.</p>
  
  <p>I am building a query as follows:</p>
  
  <pre><code>select *, case when (ordernum is null) then [largestInt] else ordernum end as newordernum
  from tableName
  order by newordernum
  </code></pre>
  
  <p>I know I could enter the value for the largest possible int for [largestInt], but I would like to replace [largestInt] with a variable.  Is this possible?</p>