Reputation: 2497
Query :
select * from <table>
Answer set :
We need to transform the above answer set as below. We need to get the column name entry in each row with their corresponding values as shown below:
Col1 Col2
JOB1 161
JOB2 38
I tried following ways from below links (But didnt work out) :
Note :
Upvotes: 0
Views: 9600
Reputation: 60513
The links you posted show both possible solutions, if you need to get the column names as values you need to write them as literals:
SELECT 'Job1', job1 FROM TAB
UNION ALL
SELECT 'Job2', job2 FROM TAB
Upvotes: 3