2012-06-27 24 views
0

我想分組行並將它們移動到同一個表中的新列中。這裏是我的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] 

如何做到這一點?

回答

相關問題