title: Error in sql query using CASE when applying formula to the column
body: <p>I have to apply the fees on the amount column in the transaction table. If the amount is greater than <code>5000</code> then I have to apply <code>17.5</code> against <strong>each transaction</strong> and take the sum in the end. If the amount is less than 5000 then I have to apply the <em>percentage formula</em> on the amount and then take the sum of it in the end. Below is my query but I am getting the below exception:</p>
  <pre><code>SELECT 
          CASE  
          When tran_amount_req &gt;= 5000 Then sum(17.5) 
          When tran_amount_req &lt; 5000 Then sum(((tran_amount_req/100) * 0.35)/100) 
          End as MyPercent
          from gstl_trans_temp
          where (message_type_mapping = '0220') and card_type ='GEIDP1'
  </code></pre>
  <p>Column <code>gstl_trans_temp.tran_amount_req</code> is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</p>
  <p>Please help, Thanks in advance.</p>