我有一个表定义如下:
CREATE TABLE GENERAL_STATISTICS.PPLP_LOAD_GENSTAT3
(
NAME VARCHAR2(100 BYTE),
START_TIME DATE,
END_TIME DATE,
ROWS_LOADED VARCHAR2(100 BYTE)
)
我想将PPLP IMPORT DATA重命名为其他内容,例如'Report1'
使用case语句但不起作用。
SELECT PPLP_NAME,
(CASE
WHEN PPLP_NAME='PPLP IMPORT DATA' THEN 'BSCS_PPL_IMP_INVOICE'
WHEN PPLP_NAME='PPLP IMPORT DATA FOR RERUN' THEN 'BSCS_PPL_IMP_USAGE_RERUN'
END)
FROM PPLP_LOAD_GENSTAT3
答案 0 :(得分:1)
您是否错过了ELSE
?
SELECT PPLP_NAME,
(CASE
WHEN PPLP_NAME='PPLP IMPORT DATA' THEN 'BSCS_PPL_IMP_INVOICE'
WHEN PPLP_NAME='PPLP IMPORT DATA FOR RERUN' THEN 'BSCS_PPL_IMP_USAGE_RERUN'
ELSE PPLP_NAME
END)
FROM PPLP_LOAD_GENSTAT3
但是你现在说你只想要一列,那就是:
SELECT CASE
WHEN PPLP_NAME='PPLP IMPORT DATA' THEN 'BSCS_PPL_IMP_INVOICE'
WHEN PPLP_NAME='PPLP IMPORT DATA FOR RERUN' THEN 'BSCS_PPL_IMP_USAGE_RERUN'
ELSE PPLP_NAME
END as PPLP_NAME
FROM PPLP_LOAD_GENSTAT3