SELECT APPROVAL_ID,count(STATION_SNAP_ID) from T_INVEST_STATION_APL
where APPROVAL_ID in (select DISTINCT PROJECT_ID from T_ARCHIVE_DETAIL where DATA_TYPE in ('1','2','3'))
and IS_DEL ='0'
GROUP BY APPROVAL_ID
HAVING count(STATION_SNAP_ID)>2;
--
UPDATE T_ARCHIVE_DETAIL a
SET a.ATTACHMENT_ID = (select id from T_PROJECT_CONTRACT_ATTACHMENT b where a.ATTACHMENT_CODE = b.ATTACHMENT_CODE)
WHERE a.ATTACHMENT_CODE IS NOT NULL and a.ATTACHMENT_ID IS NULL;
标签:CODE,笔记,更新,ID,STATION,ATTACHMENT,APPROVAL,where,HAVING From: https://www.cnblogs.com/wanqiang/p/17774731.html