看起來去JOIN其他table就行了吧
你試試看
select case when '條件A' then tableB.1
when '條件B' then tableC.1
else 0
end
as result
from tableA
join tableB on tableA.1 = tableB.1
join tableC on tableA.1 = tableC.1
將您的 Table A 改為 PERSON
CASE WHEN 裏面可以使用 SubQuery
SELECT PERSON.person_id,
PERSON.name,
(CASE WHEN LEFT(PERSON.person_id,1)='A' THEN
(SELECT SecurityUser.login_id FROM SecurityUser WHERE SecurityUser.person_id=PERSON.person_id)
ELSE
'NO DATA'
END ) AS LoginID
FROM PERSON