How to use order by on a calculated field in SQL?
<p>How to use order by on a calculated field in SQL?</p>

<pre><code>select a.Customer
    ,a.PlanTo
    ,a.Dollar01
    ,a.Dollar02
    ,a.Dollar03
    ,a.Dollar04
    ,a.Dollar05
    ,a.Dollar06
    ,a.Dollar07
    ,a.Dollar08
    ,a.Dollar09
    ,a.Dollar10
    ,a.Dollar11
    ,a.Dollar12
    ,(CAST(a.Dollar01 as decimal) + CAST(a.Dollar02 as decimal) 
    + CAST(a.Dollar03 as decimal) + CAST(a.Dollar04 as decimal) 
    + CAST(a.Dollar05 as decimal) + CAST(a.Dollar06 as decimal) 
    + CAST(a.Dollar07 as decimal) + CAST(a.Dollar08 as decimal) 
    + CAST(a.Dollar09 as decimal) + CAST(a.Dollar10 as decimal) 
    + CAST(a.Dollar11 as decimal) + CAST(a.Dollar12 as decimal)) as TOTAL1
from MDM_STAT.sds.SMarginText a
where a.salesyear = '2016'
order by a.total1
</code></pre>

<p>This is giving me 'Total1' column does not exist but as you see I have created it and is working if I am not using the <code>order by</code> clause.</p>