SELECT sla.incident_generated_sla from eventedge_events_sla sla
where e.client_id=sla.client_id and sla.priority_id=e.priority_id
(SELECT sla.incident_generated_sla from eventedge_events_sla sla
where e.client_id=sla.client_id and sla.priority_id=(IsNull(e.priority_id,"2")))
你已經幾乎做到了。
檢查這修正自己的嘗試:
SELECT sla.incident_generated_sla from eventedge_events_sla sla
where e.client_id=sla.client_id and sla.priority_id=ISNULL(e.priority_id,2)
現在,我不知道你的「E」是什麼,但如果這是你要找的CLIENT_ID宣佈,它應該工作。
仔細看看我對ISNULL的更正。
編輯:在評論這個答案是正確的;
SELECT
e.event_start_time,
sla.incident_generated_sla
FROM
eventedge_events_sla sla
left outer join eventedge_events e
ON e.client_id = sla.client_id
AND isnull(e.priority_id,2) = sla.priority_id
標記您正在使用的DBMS(MySQL,MS SQL Server等)。 –
'COALESCE'? https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#function_coalesce –