sql server - Can someone help to optimize SQL Query -


  RC.Name RiskCategory, (sum (case when IA.ImpactLevel = 'High '1 and selection 0 ED) from RTP_IMITACTI ISE JOIN RPTRIIR R RIIFFICICIDID = R. RIKIDIDRR in RICIDID (Select RTKIID = 38 and R.C.Cr. In the name of RIRRR, RC &  

by the RC News DESC 'All Group' by RC News I also very much cause to believe the same results, try this:

  select as RC.Name RiskCategory, SUM (case when IA.ImpactLevel = 'high' so join 1 and 0 end) RM_RiskCategories RC join the left & gt; on R.RiskCatrogry = RC.Name left Rpt_Risk R IA.FKRiskID = R.RiskID Where to & lt Rpt_ImpactAssess Let RC.Name; 'all' And by RC.Name order by RC.Name DESC Group  

Scope then select the (RkRiskID tap or FKItemID where the R.RiskID (Rpt_Impact = 38) FKRiskID) need all categories (had missed a point which enabled me) to do your original question really There can be a very good way of doing - I'm not really a fan to use ... where PK Nail or PK = something is something like I did the above - so surely you The above benchmark needs to be seen to be And any better.

You get that subquery a JOIN , but I'm not sure there will be any performance benefits. Still, a test may be worth, where to remove the subquery from the section, and add another to the left :

  lEFT JOIN Rpt_ImpactAssess IA Where IA.FKRiskID = R.RiskID ... and (R.RiskID zero or RI.FKItemID = 38)  

Comments