update mkf set mkf.Score= mkf.score -
(
select sum(pp.ScoreInScale) from Progresses pp
where pp.MemberKnowledgeFieldId = mkf.Id
and pp.KnowledgeId in
(select k.KnowledgeId from knowledges k where k.Code in
(
8396
,8395
,7999
,7723
,7751
,7753
,8069
,362
,7733
,7993
,8379
,7736
)
)
)
FROM NewKms_MECO..MemberKnowledgeFields mkf
where mkf.Id in
(select p.MemberKnowledgeFieldId from Progresses p
where p.KnowledgeId in
(
select k.KnowledgeId from knowledges k where k.Code in
(
8396
,8395
,7999
,7723
,7751
,7753
,8069
,362
,7733
,7993
,8379
,7736
)
)
)
We can't judge whether or not is correct without knowing what it is intended to do.
I can say it is a complete mess as far as readability and maintainability is concerned.
As far as optimized, all I can do is judge it by intuition since I know almost nothing about the tables and indexes, and the impression I get is that it is not optimized.