sql server - How to group the rows and move them into new column in the same table? -
i want group rows , move them new column in same table. here ilustration:
and query i've made far:
select month([date]) bulan, [type] tipe, sum([net qty]) total_karton, cast(sum([cm1 (rp)]) decimal) total_uang tbl_weeklyflash_id datediff(month,[date],current_timestamp) between 0 , 2 group month([date]), [type] order month([date]), [type]
how that?
you want pivot
- there's example @ http://www.mssqltips.com/sqlservertip/1019/crosstab-queries-using-pivot-in-sql-server-2005/
Comments
Post a Comment