Advertisement
bytecoded

Query #3

Mar 8th, 2019
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.96 KB | None | 0 0
  1. )INSERT INTO tt1  WITH(TABLOCK) (_Q_000_F_000_TYPE, _Q_000_F_000_RTRef, _Q_000_F_000_RRRef, _Q_000_F_001RRef, _Q_000_F_002, _Q_000_F_003RRef, _Q_000_F_004, _Q_000_F_005, _Q_000_F_006, _Q_000_F_007) SELECT
  2. T1.Fld11293_TYPE,
  3. T1.Fld11293_RTRef,
  4. T1.Fld11293_RRRef,
  5. T1.Fld11295RRef,
  6. (T1.Fld11302Turnover_ - T1.Fld11303Turnover_),
  7. T70.IDRRef,
  8. CASE WHEN CASE WHEN T1.Fld11290_TYPE = 0x08 AND T1.Fld11290_RTRef = 0x00000058 THEN T83._Fld12837 ELSE CAST(NULL AS BINARY(1)) END = 0x01 THEN (T1.Fld11302Turnover_ - T1.Fld11303Turnover_) ELSE 0.0 END,
  9. CASE WHEN (NOT ((CASE WHEN T1.Fld11290_TYPE = 0x08 AND T1.Fld11290_RTRef = 0x00000058 THEN T83._Fld12837 ELSE CAST(NULL AS BINARY(1)) END) = 0x01)) THEN (T1.Fld11302Turnover_ - T1.Fld11303Turnover_) ELSE 0.0 END,
  10. CAST(0.0 AS NUMERIC(21, 2)),
  11. CAST(NULL AS NUMERIC(21, 2))
  12. FROM (SELECT
  13. T2._Fld11290_TYPE AS Fld11290_TYPE,
  14. T2._Fld11290_RTRef AS Fld11290_RTRef,
  15. T2._Fld11290_RRRef AS Fld11290_RRRef,
  16. T2._Fld11295RRef AS Fld11295RRef,
  17. T2._Fld11293_TYPE AS Fld11293_TYPE,
  18. T2._Fld11293_RTRef AS Fld11293_RTRef,
  19. T2._Fld11293_RRRef AS Fld11293_RRRef,
  20. CAST(SUM(T2._Fld11303) AS NUMERIC(33, 8)) AS Fld11303Turnover_,
  21. CAST(SUM(T2._Fld11302) AS NUMERIC(33, 8)) AS Fld11302Turnover_
  22. FROM dbo._AccumRgTn11305 T2
  23. WHERE (((T2._Fld595 = @P1)) AND (EXISTS(SELECT
  24. 1
  25. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  26. LEFT OUTER JOIN dbo._Document233 T3
  27. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000E9 AND T2._Fld11293_RRRef = T3._IDRRef) AND (T3._Fld595 = @P2)
  28. LEFT OUTER JOIN dbo._Document212 T4
  29. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D4 AND T2._Fld11293_RRRef = T4._IDRRef) AND (T4._Fld595 = @P3)
  30. LEFT OUTER JOIN dbo._Document234 T5
  31. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000EA AND T2._Fld11293_RRRef = T5._IDRRef) AND (T5._Fld595 = @P4)
  32. LEFT OUTER JOIN dbo._Document263 T6
  33. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x00000107 AND T2._Fld11293_RRRef = T6._IDRRef) AND (T6._Fld595 = @P5)
  34. LEFT OUTER JOIN dbo._Document216 T7
  35. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D8 AND T2._Fld11293_RRRef = T7._IDRRef) AND (T7._Fld595 = @P6)
  36. LEFT OUTER JOIN dbo._Document215 T8
  37. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D7 AND T2._Fld11293_RRRef = T8._IDRRef) AND (T8._Fld595 = @P7)
  38. LEFT OUTER JOIN dbo._Document213 T9
  39. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D5 AND T2._Fld11293_RRRef = T9._IDRRef) AND (T9._Fld595 = @P8)
  40. LEFT OUTER JOIN dbo._Document199 T10
  41. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000C7 AND T2._Fld11293_RRRef = T10._IDRRef) AND (T10._Fld595 = @P9)
  42. LEFT OUTER JOIN dbo._Reference42 T11
  43. ON ((CASE WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000E9 THEN T3._Fld4625RRef WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D4 THEN T4._Fld3516RRef WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000EA THEN T5._Fld4774RRef WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x00000107 THEN T6._Fld6287RRef WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D8 THEN T7._Fld3845RRef WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D7 THEN T8._Fld3734RRef WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D5 THEN T9._Fld3600RRef WHEN T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000C7 THEN T10._Fld2840RRef ELSE CAST(NULL AS BINARY(16)) END = T11._IDRRef)) AND (T11._Fld595 = @P10)
  44. WHERE EXISTS(SELECT
  45. 0x01 AS Q_001_F_000_
  46. FROM dbo._Reference98 T12
  47. INNER JOIN dbo._Reference21 T13
  48. ON (((T12._Fld1685 = @P11) AND EXISTS(SELECT
  49. 0x01 AS Q_008_F_000_
  50. FROM dbo._InfoRg11709 T14
  51. WHERE ((T14._Fld595 = @P12)) AND ((T14._Fld12065RRef = T12._IDRRef) AND (T14._Fld12066RRef = T13._IDRRef)))) AND T13._IDRRef IN
  52. (SELECT
  53. T15._Reference21_IDRRef AS Q_009_F_000RRef
  54. FROM dbo._Reference21_VT782 T15
  55. INNER JOIN dbo._InfoRg9937 T16
  56. ON ((T16._Fld9939_TYPE = 0x08 AND T16._Fld9939_RTRef = 0x00000095 AND T16._Fld9939_RRRef = @P13) AND (T16._Fld9938_TYPE = T15._Fld7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement