Jaanna
Jaanna

Reputation: 1670

Column data as column heading

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

Answers (2)

Maddy
Maddy

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

Related Questions