title: How to use sum function in where clause in SQL Server?
body: <p>I am new to SQL Server. I want to equal two columns using <code>sum</code> function. Please find the below query.</p>
  
  <pre><code>select top 1000 
      o.orderamount, sum(oi.amount), oi.orderid 
  from 
      orders o 
  inner join 
      orderitem oi on o.orderid = oi.orderid 
  where 
      orderamount = sum(oi.amount)
  group by  
      oi.orderid, orderamount
  order by 
      oi.orderid desc
  </code></pre>
  
  <p>Whenever I execute this code, I get an error.</p>
  
  <p>Please help me.</p>