我想知道如何重构这个脚本,因为两个嵌套查询非常相似(我的数据库使用 ORACLE):
UPDATE
ALERT alert
SET
VERIFICATION_COUNT =
(
SELECT COUNT(*)
FROM TRANSCRIPTION trans
INNER JOIN DOS dos
ON trans.REF_NO = dos.REF_NO
WHERE trans.STATUS = 'ONGOING'
AND alert.VISIT = dos.VISIT
)
WHERE
alert.VISIT =
(
SELECT DISTINCT dos.VISIT FROM TRANSCRIPTION trans
INNER JOIN DOS dos
ON trans.REF_NO = dos.REF_NO
WHERE trans.STATUS = 'ONGOING'
AND alert.VISIT = dos.VISIT
);