Guest User

Untitled

a guest
Apr 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. ...
  2. FROM [fctWMAUA] (NOLOCK, INDEX(IX)) AS [t0]
  3. ...
  4.  
  5. ...
  6. FROM [fctWMAUA] (NOLOCK, INDEX(IX)) AS [t0]
  7. ...
  8.  
  9. ...
  10. FROM [fctWMAUA] (NOLOCK, INDEX(IX)) AS [t0]
  11. ...
  12.  
  13. UPDATE STATISTICS [fctWMAUA]
  14.  
  15. SET SHOWPLAN_TEXT ON
  16.  
  17. select cur.SourceSystemKey, cur.date
  18. from fctWMAUA cur
  19. left join fctWMAUA next
  20. on next.SourceSystemKey = next.SourceSystemKey
  21. and next.date > cur.date
  22. where next.SourceSystemKey is null
  23. and cur.SourceSystemKey in (1,2,3,4,5,6,7,8,9)
  24.  
  25. SELECT * FROM
  26. (
  27. SELECT MAX(t0.AsAtDateKey) AS [Date], t0.SourceSystemKey AS SourceSystem
  28. FROM fctWMAUA (NOLOCK) AS t0
  29. GROUP BY t0.SourceSystemKey
  30. )
  31. WHERE SourceSystem in (1,2,3,4,5,6,7,8,9)
  32.  
  33. SELECT [t3].[value]
  34. FROM [dimSourceSystem] AS [t0]
  35. OUTER APPLY (
  36. SELECT MAX([t2].[value]) AS [value]
  37. FROM (
  38. SELECT [t1].[AsAtDateKey] AS [value], [t1].[SourceSystemKey]
  39. FROM [fctWMAUA] AS [t1]
  40. ) AS [t2]
  41. WHERE [t2].[SourceSystemKey] = ([t0].[SourceSystemKey])
  42. ) AS [t3]
  43.  
  44. WHERE SourceSystemKey = 3
  45. GROUP BY [t0].[SourceSystemKey]
  46.  
  47. WHERE SourceSystemKey in (1,2,3,4,5,6,7,8,9)
  48.  
  49. WHERE SourceSystemKey BETWEEN 1 AND 9
  50.  
  51. WHERE SourceSystemKey >= 1 AND SourceSystemKey <= 9
  52.  
  53. SELECT MAX(AsAtDateKey) AS [Date], SourceSystemKey AS SourceSystem
  54. FROM fctWMAUA (NOLOCK)
  55. GROUP BY SourceSystemKey
  56. HAVING SourceSystemKey in (1,2,3,4,5,6,7,8,9)
Add Comment
Please, Sign In to add comment