Pivot on Oracle 10g
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using oracle 10g. I have a temp table TEMP. TEMP has following structure:- USER COUNT TYPE ---- ----- ---- 1 10 T1 2 21 T2 3 45 T1 1 7 T1 2 1 T3 I need a query which will show all types has column names,and types can have any value like T1, T2,..Tn and result will be like:- USER T1 T2 T3 ---- -- -- -- 1 17 0 1 2 0 21 1 3 45 0 0 and User column will show all the users and T1, T2 column will show total count of types. 回答1: In Oracle 10g, there was no PIVOT function but you can replicate it using an aggregate with a CASE : select usr, sum