Advertisement
bytecoded

Query #2

Mar 8th, 2019
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.96 KB | None | 0 0
  1. )SELECT
  2. T1.MonthPeriod_,
  3. T1.Fld11302Turnover_,
  4. T65.Fld12836RRef,
  5. T65.IDRRef,
  6. CAST(0.0 AS NUMERIC(21, 2)),
  7. CAST(0.0 AS NUMERIC(21, 2)),
  8. T65.IDRRef,
  9. T65.Description_,
  10. T65.Description_,
  11. T65.Fld12836RRef,
  12. T74._Description,
  13. 5.0,
  14. T74._Description
  15. FROM (SELECT
  16. DATEADD(DAY,1.0 - 1,DATEADD(MONTH,CAST(DATEPART(MONTH,T2._Period) AS NUMERIC(4)) - 1,DATEADD(YEAR,(CAST(DATEPART(YEAR,T2._Period) AS NUMERIC(4)) - 2000) - 2000,{ts '4000-01-01 00:00:00'}))) AS MonthPeriod_,
  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._Fld11302) AS NUMERIC(33, 8)) AS Fld11302Turnover_
  21. FROM dbo._AccumRgTn11305 T2
  22. WHERE (((T2._Fld595 = @P1)) AND (EXISTS(SELECT
  23. 1
  24. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  25. LEFT OUTER JOIN dbo._Document233 T3
  26. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000E9 AND T2._Fld11293_RRRef = T3._IDRRef) AND (T3._Fld595 = @P2)
  27. LEFT OUTER JOIN dbo._Document212 T4
  28. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D4 AND T2._Fld11293_RRRef = T4._IDRRef) AND (T4._Fld595 = @P3)
  29. LEFT OUTER JOIN dbo._Document234 T5
  30. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000EA AND T2._Fld11293_RRRef = T5._IDRRef) AND (T5._Fld595 = @P4)
  31. LEFT OUTER JOIN dbo._Document263 T6
  32. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x00000107 AND T2._Fld11293_RRRef = T6._IDRRef) AND (T6._Fld595 = @P5)
  33. LEFT OUTER JOIN dbo._Document216 T7
  34. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D8 AND T2._Fld11293_RRRef = T7._IDRRef) AND (T7._Fld595 = @P6)
  35. LEFT OUTER JOIN dbo._Document215 T8
  36. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D7 AND T2._Fld11293_RRRef = T8._IDRRef) AND (T8._Fld595 = @P7)
  37. LEFT OUTER JOIN dbo._Document213 T9
  38. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D5 AND T2._Fld11293_RRRef = T9._IDRRef) AND (T9._Fld595 = @P8)
  39. LEFT OUTER JOIN dbo._Document199 T10
  40. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000C7 AND T2._Fld11293_RRRef = T10._IDRRef) AND (T10._Fld595 = @P9)
  41. LEFT OUTER JOIN dbo._Reference42 T11
  42. 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)
  43. WHERE EXISTS(SELECT
  44. 0x01 AS Q_001_F_000_
  45. FROM dbo._Reference98 T12
  46. INNER JOIN dbo._Reference21 T13
  47. ON (((T12._Fld1685 = @P11) AND EXISTS(SELECT
  48. 0x01 AS Q_004_F_000_
  49. FROM dbo._InfoRg11709 T14
  50. WHERE ((T14._Fld595 = @P12)) AND ((T14._Fld12065RRef = T12._IDRRef) AND (T14._Fld12066RRef = T13._IDRRef)))) AND T13._IDRRef IN
  51. (SELECT
  52. T15._Reference21_IDRRef AS Q_005_F_000RRef
  53. FROM dbo._Reference21_VT782 T15
  54. INNER JOIN dbo._InfoRg9937 T16
  55. ON ((T16._Fld9939_TYPE = 0x08 AND T16._Fld9939_RTRef = 0x00000095 AND T16._Fld9939_RRRef = @P13) AND (T16._Fld9938_TYPE = T15._Fld784_TYPE AND T16._Fld9938_RTRef = T15._Fld784_RTRef AND T16._Fld9938_RRRef = T15._Fld784_RRRef))
  56. WHERE ((T15._Fld595 = @P14)) AND (T16._Fld595 = @P15)))
  57. WHERE ((T13._Fld595 = @P16)) AND ((CASE WHEN T11._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T11._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  58. 0x01 AS Q_002_F_000_
  59. FROM dbo._InfoRg11710 T17
  60. WHERE ((T17._Fld595 = @P17)) AND ((T17._Fld12072RRef = T13._IDRRef) AND (T17._Fld12073_TYPE = CASE WHEN T11._Fld12836RRef IS NOT NULL THEN 0x08 END AND T17._Fld12073_RTRef = CASE WHEN T11._Fld
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement