我有任何原因导致错误的表达错误?
select
CASE WHEN
(
SELECT COUNT(*) AS COUNT
FROM TRANSPLANT_ORGANS
INNER JOIN ORGAN_TYPE ON TRANSPLANT_ORGANS.TX_ORG_ID = ORGAN_TYPE.ORG_RECORD_ID
WHERE COUNT > 0
)
THEN
(
SELECT SUBSTR(CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID BETWEEN 660 AND 662 THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/KIDNEY' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID BETWEEN 640 AND 650 THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/LIVER' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID IN (620,622) THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/PANCREAS' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID IN (621) THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/PANCREAS ISLETS' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID IN (700) THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/HEART' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID IN (600) THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/LUNGS' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID BETWEEN 601 AND 607 THEN 1 ELSE 0 END) WHEN 2 THEN '/LUNGS' WHEN 0 THEN '' ELSE '/LUNG' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID IN (680) THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/INTESTINES' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID BETWEEN 685 AND 686 THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE 'SMALL INTESTINE' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID BETWEEN 683 AND 684 THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE 'LARGE INTESTINES' END,
CONCAT(CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID IN (681) THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/DUODENUM' END,
CASE SUM(CASE WHEN ORGAN_TYPE.ORG_ID IN (682) THEN 1 ELSE 0 END) WHEN 0 THEN '' ELSE '/STOMACH' END))))))))))),2,255)
FROM TRANSPLANT_ORGANS
INNER JOIN ORGAN_TYPE ON TRANSPLANT_ORGANS.TX_ORG_ID = ORGAN_TYPE.ORG_RECORD_ID
)
END
答案 0 :(得分:0)
首先,您正在从transplant_organs中检索COUNT,但之后从未进行过比较。可以移除WHERE COUNT > 0
,然后使用结束括号,您可以放置) > 0
。
其次,您的外部选择没有FROM子句。至少使用FROM dual
。
示例:
SELECT CASE
WHEN (SELECT 1 FROM dual) > 0
THEN (SELECT 'Something' FROM dual)
END
FROM dual;