SQL - CASE WHEN THEN truncates decimals
<p>The below sql query with CASE WHEN THEN returns different results. 
Note that the precision differs without the original query and with case 3 commented.
Any idea why? I am running SQL Server 2014. </p>

<pre><code>declare @d1 decimal(20, 15), @d2 decimal(20, 15), @d3 decimal(20, 15), @d4 decimal(20, 15)
set @d1 = 22.0
set @d2 = 22.0
set @d3 = 1.00000
set @d4 = 7.0

select
    case when (1 &gt; 0) then @d1 / @d4
        when (2 &gt; 0) then @d2 / @d4
        when (3 &gt; 0) then @d2 / (@d4 * @d3)
    end


--Results:
--Without case 3 commented: 3.142857
--With case 3 commented: 3.142857142857142857
</code></pre>