Your technology certification is waiting. Enroll in Cloud Class ®
CREATE TABLE your_table
SELECT 'x' col_1, 'abc' col_2 FROM DUAL
SELECT 'x', 'def' FROM DUAL
SELECT 'y', '123' FROM DUAL
SELECT 'y', '456' FROM DUAL;
SELECT col_1, MAX(DECODE(rn, 1, col_2)) col_2, MAX(DECODE(rn, 2, col_2)) col_3
FROM (SELECT col_1, col_2, ROW_NUMBER() OVER (PARTITION BY col_1 ORDER BY col_2) rn
GROUP BY col_1;
C COL COL
- --- ---
x abc def
y 123 456
2 rows selected.
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.