如图左表转成右表,case when 或者 decode 都行。谢谢大佬Thanks♪(・ω・)ノ
2条回答 默认 最新
- chuanshuo_1999 2020-11-19 14:26关注
SELECT '答案A' "答案", decode("序号”, '1', "答案A",null) "1",decode("序号”, '2', "答案A",null) "2",
decode("序号”, '3', "答案A",null) "3",decode("序号”, '4', "答案A",null) "4",decode("序号”, '5', "答案A",null) "5"
from table_name union all
SELECT '答案B' "答案", decode("序号”, '1', "答案B",null) "1",decode("序号”, '2', "答案B",null) "2",
decode("序号”, '3', "答案B",null) "3",decode("序号”, '4', "答案B",null) "4",decode("序号”, '5', "答案B",null) "5"
from table_name union all ...... 貌似有点恶心。要是序号为非固定数,就需要写存储过程了。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报