在线等,请教一个SQL语句,立即给分!
将只有PARENT, CHILD两列的表PARENT_CHILD
转换为
[解决办法]
你在用sum或者max一下,你下面的这段改一下:
select max(case when x.tp = 'First' then x.nd when x.tp is null then x.nd end) as first... from x;
[解决办法]
如下:
with ax as(
select PARENT col1 from PARENT_CHILD union
select CHILD col1 from PARENT_CHILD
)
select max(decode(col1,'A','A')) first,
max(decode(col1,'B','B')) second,
max(decode(col1,'C','C')) third,
max(decode(col1,'D','D')) fourth,
max(decode(col1,'E','E')) fifth
from ax