有没有办法使用映射表而不是对值及其替换进行硬编码?
映射表
价值 | 更换 |
---|---|
N | 模块未上交 |
电脑 | 待更正 |
LT_REVIEW_STATUS = SELECT DISTINCT A.PRUEFLOS,
CASE WHEN UPPER(A.KTEXTLOS) LIKE '%:N%' THEN 'Module Not turned In'
WHEN UPPER(A.KTEXTLOS) LIKE '%PC%' THEN 'Pending Corrections'
WHEN UPPER(A.KTEXTLOS) LIKE '%RC%' THEN 'Not yet reviewed'
WHEN UPPER(A.KTEXTLOS) LIKE '%:O%' THEN 'Close Out'
WHEN UPPER(A.KTEXTLOS) LIKE '%RV%' THEN 'Reviewed'
ELSE 'N/A' END AS REVIEW_STATUS
FROM :LT_FIRST_QALS A;
谢谢
可以通过连接到参考表来满足此要求。
给定一个参考表
CODE_LOOKUP
,如下所示:
匹配代码 | STATUS_TEXT |
---|---|
:N | 模块未上交 |
电脑 | 待更正 |
RC | 尚未审核 |
:0 | 平仓 |
房车 | 已审核 |
SELECT DISTINCT
A.PRUEFLOS
, IFNULL(CL.STATUS_TEXT, 'N/A') AS REVIEW_STATUS
FROM
:LT_FIRST_QALS A
LEFT OUTER JOIN CODE_LOOKUP CL
ON LOCATE (UPPER(A.KTEXTLOS), CL.MATCHCODE) > 0
请参阅文档
LOCATE
https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/20e3b6b77519101485e6bd62f7018f75.html