troubleshooting Question

Pivoting oracle table

Avatar of LuckyLucks
LuckyLucks asked on
DatabasesOracle Database
9 Comments1 Solution181 ViewsLast Modified:
Hi

I have a table with 3 columns of data and would like to pivot it as the result shown below, please help me with the pivot or other syntax.

CREATE TABLE pivot_test (
  id            NUMBER,
  customer_id   NUMBER,
  COURSE  VARCHAR2(5),
  GRADE   VARCHAR(25)
);

INSERT INTO pivot_test VALUES (1, 1, 'A', 'GOOD');
INSERT INTO pivot_test VALUES (2, 1, 'B', 'GOOD');
INSERT INTO pivot_test VALUES (3, 1, 'C', 'GOOD');
INSERT INTO pivot_test VALUES (4, 2, 'A', 'BAD');
INSERT INTO pivot_test VALUES (5, 2, 'C', 'POOR');
INSERT INTO pivot_test VALUES (6, 3, 'A', 'GOOD');
INSERT INTO pivot_test VALUES (7, 3, 'B', 'POOR');
INSERT INTO pivot_test VALUES (8, 3, 'C', 'GOOD');
INSERT INTO pivot_test VALUES (9, 4, 'A', 'POOR');

select * from pivot_test;



 
                                            A                          B                                  C
 
 CUSTOMERID   Good Bad Poor     Good Bad Poor         Good Bad Poor
 
 1                              1                            1                                    1
 2                                      1                                                                              1
 3                               1                                            1                    1
4                                              1
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros