title: source pivot does not like column names
body: <p>I have a query below. However in the last select two fields, USDVal &amp; cp are invalid column names when I run the query. I do not understand why though?</p>
  
  <p>Because if I run the query below excluding the last line ("as source..") the query runs.</p>
  
  <pre><code>;with s as
  (
     select cp, mktVal, date 
     from tblDaily
     where date = '2017-01-30' and id = 'SFAB'
  ), h as 
  (
      select idMK, name, cp, wgt 
      from tblDrift 
      where date = '2017-03-30' and idSub = 'V12' and wgt &lt;&gt; 0
  ), m as
  (
     select h.idMK, h.name, h.wgt * s.mktVal  as USDVal, h.cp
     from h left join s on h.cp = s.cp
  )   
  select idMK, name, USDVal, cp from m 
  as source pivot(max(USDVal) for cp in ([BPP],[NCV])) as pvt
  </code></pre>