tsql where clause find a value from subquery's top 1 value -
We have a slow query like this:
T.id = tl TaskLog tl on id where tl.PostImage = (select the top 1 tll.PostImage from TaskLog tll where tll.id = t.id) group t1.PostImage, t.id It looked like tl.PostImage = (subquery) was due to slow speed. How do I write it to run faster?
EDIT:
I have simplified this question because of this the solution was not helping me. Here is the real query:
Include TOSP_Log PL in Task P internal PLOS work with TotalReferrals as Separate Selection (p.Task_id), 1. Task_ID = P.Task_ID where (MONTH (P. CreateDate) = @manth and year (p. Credited) = @ year) and (('k3%' and p. Crated end lieutenant; '12 / 6/2010 ' Such as P. Varkar) (or '(' K2 ',' k27 ',' k29 ') and P. credited & gt; = '12 / 6/2010' and P. Date modified '12 / 1/2013 ') Or (Select the top 1 pll.post_image from P.Worker In ('K4A' 'K46', 'K48') and P.Credated Data); or (pl.post_image = (Task_log pll where pll.Task_id = p.Task_id And pll .pre_image = 'unknown' and pll.changed_column_nm = 'worker' and (month (pll.CreateDate) = @month and year (pll.CreateDate) = @ year) and ((pll.post_image such as' k3% 'And pll. (' K22 ',' k27 ',' k29 ') and pll.CreateDate & gt; = '12 / 6/2010' in pll.post_image and pll.CreateDate & lt; '12 / 1/2013 ' Pll.post_image ('K4A', 'K46', '48') and pll.CreateDate> , Select from p.Task_id, pl.CreateDate
Join Task T Inner T.L. on TaskLog TL = TL.Post Image by TL.ID Group
Comments
Post a Comment