Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question, Pradeep.
Asked: August 14, 2012 - 2:41 am UTC
Last updated: August 15, 2012 - 9:51 am UTC
Version: 11.2.0.2.0
Viewed 50K+ times! This question is
Rajeshwaran Jeyabal, August 15, 2012 - 10:25 am UTC
rajesh@ORA11GR2> rajesh@ORA11GR2> select * 2 from ( 3 select deptno,job 4 from emp 5 ) 6 pivot 7 ( count(*) 8 for deptno in (10,20,30) ) 9 / JOB 10 20 30 --------- ---------- ---------- ---------- CLERK 1 2 1 SALESMAN 0 0 4 PRESIDENT 1 0 0 MANAGER 1 1 1 ANALYST 0 2 0 Elapsed: 00:00:00.21 rajesh@ORA11GR2> rajesh@ORA11GR2> select * 2 from ( 3 select deptno,job 4 from emp 5 ) 6 pivot 7 ( count(*) 8 for deptno in (select deptno from dept) ) 9 / for deptno in (select deptno from dept) ) * ERROR at line 8: ORA-00936: missing expression Elapsed: 00:00:00.00 rajesh@ORA11GR2> rajesh@ORA11GR2> rajesh@ORA11GR2> column deptno_xml format a30 trunc; rajesh@ORA11GR2> select * 2 from ( 3 select deptno,job 4 from emp 5 ) 6 pivot XML 7 ( count(*) 8 for deptno in (select deptno from dept) ) 9 / JOB DEPTNO_XML --------- ------------------------------ ANALYST <PivotSet><item><column name = CLERK <PivotSet><item><column name = MANAGER <PivotSet><item><column name = PRESIDENT <PivotSet><item><column name = SALESMAN <PivotSet><item><column name = Elapsed: 00:00:00.09 rajesh@ORA11GR2>
Laurent Schneider, August 15, 2012 - 11:15 am UTC
A reader, April 25, 2017 - 9:45 am UTC
Share and learn SQL and PL/SQL; free access to the latest version of Oracle Database!
Classes, workouts and quizzes on Oracle Database technologies. Expertise through exercise!