Oracle newbie here just trying to learn something.
I have a query that returns two rows per ID:
SELECT B1_ALT_ID, B1_CHECKLIST_COMMENT
FROM PERMIT
WHERE (B1_CHECKBOX_DESC = 'Certificate Number'
OR B1_CHECKBOX_DESC = 'DIF_Category');
Current Output
Instead of two rows, how can I put the two varying values in the B1_CHECKLIST_COMMENT column into two separate columns?
Visually, here's what I'm looking to achieve:
Desired Output
B1_ALT_ID B1_CHECKLIST_1 B1_CHECKLIST_2
DIF13-0001 27654 Fiber
DIF13-0002 1380 Water
DIF13-0003 736 Library
I'm using Oracle version 12.1.
You can use
PIVOT
:Or conditional aggregation:
Which, for the sample data:
Both output:
db<>fiddle here