is this query correct and optimize?

  • hello friends

     

    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
    )
    )
    )

  • For readability I suggest indents , but more importantly this looks like it could use EXISTS clauses and not sure why the same values criteria appear more than once.

    ----------------------------------------------------

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply