title: SUM IIF expression result
body: <p>in this select i need the sum result the IIF expression, but when i execute this query obtain only first IIF statement. Any suggestion?? Thanks</p>
  
  <pre><code>SELECT conto, desconto, date, codoperaio, SUM(IIF(totcasse ='1',SUM(totcasse),0)+
                                                IIF(totcasse ='6',SUM(totcasse*3),0)+
                                                IIF(totcasse ='8',SUM(totcasse*4),0)+
                                                IIF(totcasse ='10',SUM(totcasse*5),0)) as Kilogrammi
  FROM dbo.Import
  where totcasse BETWEEN 1 and 10
  Group by conto, desconto, date,codoperaio, totcasse
  </code></pre>