0

How can I use rotate/pivot my table in sql?

my table looks like this:

INTEGRATION STATUS
INT 1 completed
INT 2 FAILED
INT 3 Aborted

I want this:

Completed Failed Aborted
INT 1 INT 2 INT 3

1 Answers1

0

for example:

with 
datum (INTEGRATION, STATUS)
as (
select 'INT 1','completed' from dual union all
select 'INT 2','FAILED' from dual union all
select 'INT 3','Aborted' from dual
)
select * from datum
pivot 
(
max(integration)
for status in ('completed' as "Completed",'FAILED' as "Failed",'Aborted' as "Aborted")
) ;

enter image description here

links: pivot/unpivot

How to Convert Rows to Columns

pivoting example