title: SQL Server 2012 Case statement cannot update what I need it to update
body: <p>I'm trying to figure out how to make this formula work for my SQL Server 2012, and it has me completely stumped. In the first <code>case</code> statement where I am trying to set the <code>Dateupdated</code> column, on the middle line, I have it as </p>
  
  <pre><code>WHEN standardunitcost &gt; (averageunitcost + 2.000000) THEN GETDATE()
  </code></pre>
  
  <p>I need to add something extra in there to make sure that the <code>(Averageunitcost + 2.000000)</code> is greater than 22. When I try to set it up as <code>((Averageunitcost + 2.000000) &gt; 22.000000)</code> it is incompatible.</p>
  
  <p>Can someone explain to me why I cannot do it the way I am currently trying, and how to make this work properly? Also, I'm sorry if this is in the incorrect place, or has been asked before, but I'm not really sure what to search for to solve this!</p>
  
  <pre><code>UPDATE [mas_wgd].[dbo].[CI_Item]
  SET dateupdated = CASE
                       WHEN StandardUnitCost &lt; AverageUnitCost THEN GETDATE()
                       WHEN standardunitcost &gt; (AverageUnitCost + 2.000000) THEN GETDATE()
                       WHEN StandardUnitCost &lt; 22.000000 THEN GETDATE()
                       ELSE dateupdated
                    END
  WHERE ProductLine IN ('A010', 'A020', 'A030', 'A040', 'A050', 'A060', 'A070', 'A080', 'A090', 'A100', 'A110', 'A120', 'A130', 'A130', 'A140', 'A150', 'A200', 'A250', 'A300', 'A350', 'A400', 'A450', 'A500', 'A550', 'A600', 'AGNC', 'C010', 'C020', 'C030', 'C040', 'C050', 'C060', 'C070', 'C080', 'C090', 'C100', 'C110', 'C120', 'C130', 'C130', 'C140', 'C150', 'C200', 'C250', 'C300', 'C350', 'C400', 'C450', 'C500', 'C550', 'C600', 'CGNC')
  
  UPDATE [mas_wgd].[dbo].[CI_Item]
  SET Standardunitcost = CASE
                            WHEN (AverageUnitCost between 0.010000 and 22.000000) THEN 22.00000
                            WHEN AverageUnitCost &gt; 22.000000 THEN AverageUnitCost + 2.000000
                            ELSE StandardUnitCost 
                          END
  WHERE ProductLine IN ('A010', 'A020', 'A030', 'A040', 'A050', 'A060', 'A070', 'A080', 'A090', 'A100', 'A110', 'A120', 'A130', 'A130', 'A140', 'A150', 'A200', 'A250', 'A300', 'A350', 'A400', 'A450', 'A500', 'A550', 'A600', 'AGNC', 'C010', 'C020', 'C030', 'C040', 'C050', 'C060', 'C070', 'C080', 'C090', 'C100', 'C110', 'C120', 'C130', 'C130', 'C140', 'C150', 'C200', 'C250', 'C300', 'C350', 'C400', 'C450', 'C500', 'C550', 'C600', 'CGNC')
  </code></pre>