Reputation: 1670
I am facing a very nasty problem to create reports. For this, I would like to have column data as column headers.
Tables: skill_table
SKILL_ID | NAME
3431060 | Stomach
3431064 | Hand
3437806 | Finger
localnode_table (which actually has the order/alignment (like what is next and what is previous) of the name from skill table.
NODE_ID | PREVIOUS_ID | NEXT_ID
3431060 | | 3431064
3431064 | 3431060 | 3437806
3437806 | 3431064
How to make it appear like:
Stomach | Hand | Finger
3431060 | 3431064 | 3437806
Upvotes: 0
Views: 1518
Reputation: 3816
This should work for your requirement,
SELECT
( SELECT SKILL_ID FROM skill_table WHERE name = 'Stomach'),
( SELECT SKILL_ID FROM skill_table WHERE name = 'Hand'),
( SELECT SKILL_ID FROM skill_table WHERE name = 'Finger')
FROM dual
UNION ALL
SELECT
( SELECT NAME FROM skill_table WHERE name = 'Stomach'),
( SELECT NAME FROM skill_table WHERE name = 'Hand'),
( SELECT NAME FROM skill_table WHERE name = 'Finger')
FROM dual;
Upvotes: 0
Reputation: 16677
check out this topic
http://www.simple-talk.com/sql/t-sql-programming/creating-cross-tab-queries-and-pivot-tables-in-sql/
and oracle specific
https://forums.oracle.com/forums/thread.jspa?messageID=1036809
Upvotes: 1