0

Very basic question

Right now my query is like

select table.a, table.b, table.c from table

A   B    C  

1   2    3

.

I need my output to be

NAME    ID
A       1
B       2
C       3

.

Is there a way that I can pivot my current output or query this table in a different way?

Thanks!

0

2 Answers 2

1

You need UNPIVOT:

select * from table1 unpivot (id for name in (a,b,c));
Sign up to request clarification or add additional context in comments.

Comments

0
Select 'A' as name, (
    select A 
        from table1
        ) as ID
union all
Select 'B', (
    select B 
        from table1
    ) as ID
union all
Select 'C', (
    select C 
        from table1
    ) as ID

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.