daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest May 17th, 2018 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. update t1
  2. set t1.CollectedData_ID = res.CollectedData_ID
  3. from Tasks t1
  4. join ImportSessions i1 on i1.ImportSession_ID = t1.ImportSession_ID
  5. join dbo.Periods p1 on i1.Session_Date between p1.Date_Begin and ISNULL(p1.Date_End, GETDATE()+1)
  6. join (
  7.     select t.Task_ID, MAX(cd.CollectedData_ID)  CollectedData_ID
  8.     from CollectedData cd
  9.     join Tasks t on t.Task_ID = cd.Task_ID
  10.     join ImportSessions i on i.ImportSession_ID = t.ImportSession_ID
  11.     join dbo.Periods p on i.Session_Date between p.Date_Begin and ISNULL(p.Date_End, GETDATE()+1)
  12.     where p.Period_ID = 35
  13.     and cd.Controller_ID = 12847
  14.     and cd.CollectedData_ID<t.CollectedData_ID
  15.     group by t.Task_ID
  16. ) res on t1.Task_ID = res.Task_ID
  17. join CollectedData res_cd on res.CollectedData_ID = res_cd.CollectedData_ID
  18. join CollectedData cd1 on t1.CollectedData_ID = cd1.CollectedData_ID
  19. where
  20. p1.Period_ID=35
  21. and cd1.Controller_ID = 39216
  22. and isnull(cd1.Check_Value,cd1.TypicalCase_ID) = ISNULL(res_cd.Check_Value, res_cd.TypicalCase_ID)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top