title: Calculate Percentage of a Value in a Row With Decimals Rounded to 2 Places
body: <p>I have a query that gives me the percentage of NULL values in a column:</p>
  
  <pre><code>SELECT
    Count(*)
  FROM
    XYZ_Referrals
  WHERE
    referral_source IS NULL
  ) * 100.0 / (
    Select
      Count(*)
    From
      XYZ_Referrals
  ) as 'referral source fields that are populated'
  </code></pre>
  
  <p>However, I need to round and truncate the value to only 2 decimal places. The following query rounds, but does not truncate:</p>
  
  <pre><code>SELECT
    Round
      (
          (
              (
                  SELECT
                      Count(*)
                  FROM
                      XYZ_Referrals
                  WHERE
                      referral_source IS NULL
              )
          * 100.0 / Count(*)
          ),2,2
      )
      as 'referral source fields that are populated'
  FROM
    XYZ_Referrals
  </code></pre>
  
  <p>The value returned is 5.600000000000</p>
  
  <p>I've attempted CAST, with no success.</p>
  
  <pre><code>SELECT
      (
          Cast
              (
                  Round
                      (
                          (
                              (
                                  SELECT
                                      Count(*)
                                  FROM
                                      XYZ_Referrals
                                  WHERE
                                      referral_source IS NULL
                              )
                              * 100.0 / Count(*)
                          )
                      ),2
                  AS DECIMAL(3,2)
              )
      )
      as 'referral source fields that are populated'
  FROM
    XYZ_Referrals
  </code></pre>
  
  <p>Any assistance is appreciated.</p>