SQL Server - Need Single query which performs Select or Update based on condition
<p>I have a table <code>Order</code> with columns <code>Id</code> and <code>amount</code>.</p>

<p>I need a query which returns all the records where amount > 200, and if amount &lt; 200, it should update amount and return amount.</p>

<pre><code>ID    Amount
1     250
2     190
3      50
4     200
</code></pre>

<p>Now I need single query 
which <code>select sum(amount) from order where amount &gt; 200</code>  for <code>Id</code> 1 and 4</p>

<p>but for 2 and 3 it should fire Update query <code>Update order set amount = 200 where amount &lt; 200</code>
 first and then it should fire <code>select sum(amount) from order where amount &gt; 200</code></p>

<p>Hope i am clear with requirement this time</p>

<p>Please help me.</p>