如何对行进行分组并将它们移动到同一个表中的新列中?

时间:2012-06-27 08:18:11

标签: sql-server

我想将行分组并将它们移动到同一个表中的新列中。这是我的ilustration: table ilustration

这是我到目前为止所做的查询:

SELECT 
    month([date]) as bulan, 
    [type] as tipe,
    SUM([net qty]) total_karton, 
    CAST(SUM([cm1 (rp)]) as decimal) as total_uang
FROM 
    tbl_weeklyflash_ID
WHERE
    DATEDIFF(month,[date],CURRENT_TIMESTAMP) between 0 and 2
GROUP BY 
    month([date]),
    [type]
ORDER BY 
    month([date]), [type]

怎么做?

1 个答案:

答案 0 :(得分:1)