SELECT CASE
WHEN 'XIYAO' = 'XIYAO' THEN
'XIYAO'
END XIYAO,
CASE
WHEN 'ZHONGYAO' = 'ZHONGYAO' THEN
'ZHONGYAO'
END ZHONGYAO,
CASE
WHEN 'QITA' = 'QITA' THEN
'QITA'
END QITA
FROM DUAL;
#2
列是固定的,我是想在列名下面显示该列对应的金额(je),我就是这 显示金额不会写...
#3
SELECT decode(LXMC,'检查',JE,NULL) AS '检查',....FROM
#4
SELECT CASE
WHEN 'XIYAO' = 'XIYAO' THEN
DECODE((T.JE,'NULL', 0, T.JE)
END XIYAO,CASE
WHEN 'ZHONGYAO' = 'ZHONGYAO' THEN
DECODE((T.JE,'NULL', 0, T.JE)
END ZHONGYAO,CASE
WHEN 'QITA' = 'QITA' THEN
DECODE((T.JE,'NULL', 0, T.JE)
END QITA FROM TABLE T;
#5
刚才的多了个括号
SELECT CASE
WHEN 'XIYAO' = 'XIYAO' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END XIYAO,
CASE
WHEN 'ZHONGYAO' = 'ZHONGYAO' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END ZHONGYAO,
CASE
WHEN 'QITA' = 'QITA' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END QITA
FROM DUAL T;
SELECT ID,sum(decode(LXMC,'检查',JE,NULL)) AS '检查',....FROM table GROUP BY ID
非常感谢,我得出想要的结果了~
#10
非常感谢 gioh0022 的解答,我得出了想要的结果,也非常感谢 zlloct ,辛苦了
#1
如果你的列名是固定的个数就好做,给你个例子参考:
SELECT CASE
WHEN 'XIYAO' = 'XIYAO' THEN
'XIYAO'
END XIYAO,
CASE
WHEN 'ZHONGYAO' = 'ZHONGYAO' THEN
'ZHONGYAO'
END ZHONGYAO,
CASE
WHEN 'QITA' = 'QITA' THEN
'QITA'
END QITA
FROM DUAL;
#2
列是固定的,我是想在列名下面显示该列对应的金额(je),我就是这 显示金额不会写...
#3
SELECT decode(LXMC,'检查',JE,NULL) AS '检查',....FROM
#4
列是固定的,我是想在列名下面显示该列对应的金额(je),我就是这 显示金额不会写...
SELECT CASE
WHEN 'XIYAO' = 'XIYAO' THEN
DECODE((T.JE,'NULL', 0, T.JE)
END XIYAO,CASE
WHEN 'ZHONGYAO' = 'ZHONGYAO' THEN
DECODE((T.JE,'NULL', 0, T.JE)
END ZHONGYAO,CASE
WHEN 'QITA' = 'QITA' THEN
DECODE((T.JE,'NULL', 0, T.JE)
END QITA FROM TABLE T;
#5
列是固定的,我是想在列名下面显示该列对应的金额(je),我就是这 显示金额不会写...
刚才的多了个括号
SELECT CASE
WHEN 'XIYAO' = 'XIYAO' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END XIYAO,
CASE
WHEN 'ZHONGYAO' = 'ZHONGYAO' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END ZHONGYAO,
CASE
WHEN 'QITA' = 'QITA' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END QITA
FROM DUAL T;
SELECT CASE
WHEN 'XIYAO' = 'XIYAO' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END XIYAO,
CASE
WHEN 'ZHONGYAO' = 'ZHONGYAO' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END ZHONGYAO,
CASE
WHEN 'QITA' = 'QITA' THEN
DECODE(T.JE, 'NULL', 0, T.JE)
END QITA
FROM DUAL T;