My Oracle Support Banner

How To Pivot Data in 11g and Before Using SQL (Doc ID 1357332.1)

Last updated on NOVEMBER 25, 2019

Applies to:

Oracle Database - Enterprise Edition - Version 8.1.7.4 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
** Checked for relevance 13-Feb-2013 **

Goal

NOTE: In the images and/or the document content below, the user information and environment data used represents fictitious data from the Oracle sample or built-in schema(s), Public Documentation delivered with an Oracle database product or other training material. Any similarity to actual environments, actual persons, living or dead, is purely coincidental and not intended in any manner.

 

 

Transform the following rows of data

SQL> select * from sales;


REP YEAR SALE
---------- ----------
john 2011 100
john 2011 100
john 2009 100
john 2011 100
john 2010 100


to display as this:


REP    2009      2010       2011
----  ------   --------    -------
john    100      100          300



Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.