SELECT 编号, SUM(CASE WHEN (DATEPART(mm, y.dates))
= 1 THEN sl END) '1月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 2 THEN sl END) '2月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 3 THEN sl END) '3月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 4 THEN sl END) '4月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 5 THEN sl END) '5月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 6 THEN sl END) '6月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 7 THEN sl END) '7月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 8 THEN sl END) '8月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 9 THEN sl END) '9月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 10 THEN sl END) '10月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 11 THEN sl END) '11月份', SUM(CASE WHEN (DATEPART(mm, y.dates))
= 12 THEN sl END) '12月份'
FROM TABLE GROUP BY 编号
// SL是金额