我发现“CASE WHEN”语句对我的查询非常有用。但这是我的查询(仅选择):
SELECT dbo.ARCHIVE.SYSTEM_KEY AS PROTOCOLLO,
CASE dbo.ARCHIVEDEST.ERR_ID WHEN 0 THEN 'OK' ELSE 'KO' END AS ESITO,
CASE WHEN dbo.ARCHIVEDEST.XMODE IN ('R', 'K', 'H') THEN 'RX' ELSE 'TX' END AS 'T/R',
CASE 'T/R' WHEN 'TX' THEN CONTACTORIGIN.address ELSE CONTACTDESTINATION.address END AS Utente,
问题出在第三个 Case 语句上,因为不评估以前的“T/R”查询(对于所有记录,它返回“CONTACTORIGIN.address”。有可能做到这一点?或者我走错路了?