--设置有多个主负责人的组织只有一个主负责人
UPDATE T_HBSS_WORKROLES
   SET FMAINPEOINCHARGE = '0'
 WHERE FID IN (SELECT FID FROM (SELECT W.FID
                 FROM T_HBSS_WORKROLES W,
                      (SELECT FADMINORGID, MAX(FID) MFID
                         FROM T_HBSS_WORKROLES T
                        WHERE FMAINPEOINCHARGE = '1'
                          AND FENABLE = '1'
                        GROUP BY FADMINORGID
                       HAVING COUNT(1) > 1) T
                WHERE W.FADMINORGID = T.FADMINORGID
                  AND W.FMAINPEOINCHARGE = '1'
                  AND W.FENABLE = '1'
                  AND W.FID != T.MFID) A);