创建报告时我遇到了一个非常讨厌的问题。为此,我希望将列数据作为列标题。
表: 的 skill_table
SKILL_ID | NAME
3431060 | Stomach
3431064 | Hand
3437806 | Finger
localnode_table (实际上具有技能表中名称的顺序/对齐方式(如下一步和前一步)。
NODE_ID | PREVIOUS_ID | NEXT_ID
3431060 | | 3431064
3431064 | 3431060 | 3437806
3437806 | 3431064
如何让它看起来像:
Stomach | Hand | Finger
3431060 | 3431064 | 3437806
答案 0 :(得分:1)
查看此主题
http://www.simple-talk.com/sql/t-sql-programming/creating-cross-tab-queries-and-pivot-tables-in-sql/
和oracle特定的
https://forums.oracle.com/forums/thread.jspa?messageID=1036809
答案 1 :(得分:0)
这应该适合您的要求,
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;