我有这样的声明:
SELECT *
FROM sgtn
WHERE sgtn_kun_id IN (SELECT DISTINCT kun_id
FROM sgtn, kun
WHERE kun.kun_e_mail IN (LONG LIST OF EMAILS)
AND sgtn_kun_id = kun_id)
AND sgtn_strasse IN (SELECT sgtn.sgtn_strasse
FROM sgtn
WHERE sgtn_kun_id IN (SELECT DISTINCT kun_id
FROM sgtn, kun
WHERE kun.kun_e_mail IN (LONG LIST OF EMAILS)
AND sgtn_kun_id = kun_id)
GROUP BY sgtn.sgtn_strasse
HAVING COUNT(sgtn_strasse) > 2);
LONG LIST OF EMAILS
即:'abc@domain.com','def@domain.com',。. . 'xyz@domain.com'
如您所见,我在此查询中重复了部分子查询。
我想知道是否以及如何替换LONG LIST OF EMAILS
. 它在我的陈述中出现了两次。是否可以编辑此查询,以便提到的内容LONG LIST OF EMAILS
发生一次?