Get percentage of two subselect from DB
<p>I have a table, and I need to count two different columns in subselect. I've got something like this:</p>

<pre><code>SELECT
    COUNT(z.id_contract) AS countOfContracts,
    (
        SELECT COUNT(zml.id_contract) FROM [DW].[dbo].[DW_D_CONT] AS zml 
        WHERE zml.p_akt= 'A' 
        AND d_start_dw &gt; '2013-01-01'
        AND d_start_dw &lt; '2013-01-31'
    ) AS januar,
    (
        SELECT COUNT(zml.id_contract) FROM [DW].[dbo].[DW_D_CONT] AS zml 
        WHERE zml.p_akt= 'A' 
        AND d_start_dw &gt; '2013-02-01'
        AND d_start_dw &lt; '2013-02-28'
    ) AS februar
     FROM ...
</code></pre>

<p>I need to do something like </p>

<pre><code>januar / februar * 100
</code></pre>

<p>However the alliases doesn't work in subselects. So I thought about something like this:</p>

<pre><code>    (
        (SELECT COUNT(zml.id_contract) FROM [DW].[dbo].[DW_D_CONT] AS zml 
        WHERE zml.p_akt= 'A' 
        AND d_start_dw &gt; '2013-01-01'
        AND d_start_dw &lt; '2013-01-31')
    )
    /
    (
        (SELECT COUNT(zml.id_contract) FROM [DW].[dbo].[DW_D_CONT] AS zml 
        WHERE zml.p_akt= 'A' 
        AND d_start_dw &gt; '2013-02-01'
        AND d_start_dw &lt; '2013-02-28')
    )
</code></pre>

<p>So I am trying to get count of "januar" and "februar" like a subtask (you can see there's different dates), but I always receive 100%. I'm absolutely sure, that count of januar and of februar is DIFFERENT</p>

<p>Can somone help me?</p>