IF statement in ORDER BY clause
<p>I am struggling with the syntax of getting an if statement or case statement in an order by clause.  </p>

<p>Here is my current code:</p>

<pre><code>order by 
    case WHEN (col.line_item_no != 0) THEN Parent_Catalog_Desc,
                 col.line_no, spc.attr_value, col.line_item_no ELSE
       Parent_Catalog_Desc, col.line_no END 
</code></pre>

<p>Says I am missing a keyword.  Let me know if you need more context.</p>

<p>Basically, if the line_item_no field is NOT 0, it follows that first sort order, if it IS 0, i use a different sort order.</p>