日期:2014-05-17 浏览次数:20541 次
UPDATE a SET a.RatingCode=5 FROM Account a RIGHT JOIN e__ManagementDetail md ON md.c__khmc=a.AccountId
WHERE datediff(yy,md.createdOn,getdate())<=2 GROUP BY md.c__khmc HAVING sum(md.c__dkje)>=100000
UPDATE Account
SET RatingCode=5
FROM
(
select md.c__khmc
from e__ManagementDetail md
where datediff(yy,md.createdOn,getdate())<=2
GROUP BY md.c__khmc
HAVING sum(md.c__dkje)>=100000
) md
left join Account a
ON md.c__khmc=a.AccountId
UPDATE a
SET a.RatingCode = 5
FROM Account a
RIGHT JOIN ( SELECT c__khmc ,
SUM(c__dkje) c__dkje
FROM e__ManagementDetail
WHERE DATEDIFF(yy, md.createdOn, GETDATE()) <= 2
GROUP BY c__khmc
HAVING SUM(c__dkje) >= 100000
) md ON md.c__khmc = a.AccountId