pivot day of the month from row to column with sum value
<p>I have a data with sum value  and mapping to the day that matched with this SQL</p>

<blockquote>
  <p>sample data and code</p>
</blockquote>

<p><a href="http://sqlfiddle.com/#!3/ca364/6" rel="nofollow">http://sqlfiddle.com/#!3/ca364/6</a></p>

<p>but my problem is I can't pivot a date row to column
i need to pivot (query from sqlfiddle above) to shown as this example</p>

<pre><code>Date                1   2   3   4   5   6   7   8   9 to end of the month
TAS0B065B999P999    0   0   0   0   0   4900    9900    0   -96600
TAS1B065B999P999    0   0   0   0   0   0   0   0   0
TAS2B065B999P999    0   0   0   0   0   0   0   0   0
TAS3B065B999P999    0   0   0   0   0   0   0   0   0
TAS4B065B999P999    0   0   0   0   0   0   0   0   0
TAS5B065B999P999    0   0   0   0   0   0   0   0   0
TAS6B065B999P999    0   0   0   0   0   0   0   0   0
TAS7B065B999P999    0   0   0   0   0   0   0   0   0
TAS8B065B999P999    0   0   0   0   0   0   0   0   0
TAS9B065B999P999    0   0   0   0   0   0   0   0   0
TASAB065B999P999    0   0   0   0   0   0   0   0   0
TDS1B065B999P999    0   0   0   0   0   0   0   0   0
TDS2B065B999P999    0   0   0   0   0   0   0   0   0
TDS3B065B999P999    0   0   0   0   0   0   0   0   0
TRS1B065B999P999    0   0   0   0   0   0   0   0   0
TRS2B065B999P999    0   0   0   -72900  0   74900   -74900  90900   0
TRS3B065B999P999    0   0   0   21100   0   0   0   0   0
</code></pre>

<blockquote>
  <p>Sample code</p>
</blockquote>

<pre><code>WITH t1
     AS (SELECT dt,TERM,
                SumCashOUT,
                DATEADD(MONTH, DATEDIFF(MONTH, '1900-01-01', dt), '1900-01-01') AS firstInMonth,
                DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, '1900-01-01', dt)+1, '1900-01-01')) AS lastInMonth
         FROM
         (
             SELECT CONVERT(  DATE, TA_DATE) AS dt,TERM,
                    DATENAME(dw, CONVERT( DATE, TA_DATE)) AS dn,
                    DATEPART(DW, CONVERT( DATE, TA_DATE)) AS dtdw,
                    OUT1 + OUT2 + OUT3 + OUT4 AS SumCashOUT
             FROM CASH1609

             GROUP BY TA_DATE,
                      TERM,
                      OUT1,
                      OUT2,
                      OUT3,
                      OUT4
         ) AS st
         GROUP BY dt,TERM,
                  dn,
                  dtdw,
                  SumCashOUT),
     Calendar
     AS (SELECT DISTINCT
                DATEADD(Day, c.number, t1.firstInMonth) AS d
         FROM t1
              JOIN master..spt_values AS c ON type = 'P'
                                              AND DATEADD(DAY, c.number, t1.firstInMonth) BETWEEN t1.firstInMonth AND t1.lastInMonth)
     SELECT DATEPART(dd, d) AS Date,TERM,

            CASE
                WHEN CONVERT( NUMERIC(16, 0), SumCashOUT) IS NULL
                THEN 0
                ELSE CONVERT(NUMERIC(16, 0), SumCashOUT)
            END AS SumCashOUT
     FROM calendar AS c
          LEFT JOIN t1 ON t1.dt = c.d
          LEFT JOIN holiday ON c.d = holiday.HDATE

     ORDER BY DAte ASC;
</code></pre>