16.02.2018
1 Yorum
Merhaba ;
İş hayatımızın vazgeçilmesi olan Pivot işlevini direk SQL ile kullanmak isteyenler için ,
--PIVOT TASARIM MODELI SELECT * FROM ( SELECT * FROM dbo.table_name ) t PIVOT ( SUM(aggregated_column) FOR header_column IN ([pivoted_column1], [pivoted_column2]) ) p --UNPIVOT TASARIM MODELI SELECT * FROM dbo.table_name UNPIVOT ( column_value FOR column_code IN (column_name1, column_name2) ) unpvt
--PIVOT TASARIM MODELI
SELECT * FROM ( SELECT * FROM dbo.table_name ) t PIVOT ( SUM(aggregated_column) FOR header_column IN ([pivoted_column1], [pivoted_column2]) ) p
--UNPIVOT TASARIM MODELI
SELECT * FROM dbo.table_name UNPIVOT ( column_value FOR column_code IN (column_name1, column_name2) ) unpvt