Advertisement
bytecoded

TempDB Query Top 5 (SQL)

Mar 23rd, 2019
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 43.14 KB | None | 0 0
  1. (@P1 numeric(10),@P2 numeric(10),@P3 nvarchar(4000),@P4 numeric(10),@P5 varbinary(16),@P6 numeric(10),@P7 numeric(10),@P8 numeric(10),@P9 numeric(10),@P10 numeric(10),@P11 datetime2(3),@P12 numeric(10),@P13 numeric(10),@P14 numeric(10),@P15 numeric(10),@P16 nvarchar(4000),@P17 numeric(10),@P18 varbinary(16),@P19 numeric(10),@P20 numeric(10),@P21 numeric(10),@P22 numeric(10),@P23 numeric(10),@P24 datetime2(3),@P25 datetime2(3),@P26 nvarchar(4000),@P27 numeric(10),@P28 varbinary(16),@P29 numeric(10),@P30 numeric(10),@P31 numeric(10),@P32 numeric(10),@P33 numeric(10),@P34 numeric(10),@P35 numeric(10),@P36 numeric(10),@P37 nvarchar(4000),@P38 numeric(10),@P39 varbinary(16),@P40 numeric(10),@P41 numeric(10),@P42 numeric(10),@P43 numeric(10),@P44 numeric(10),@P45 numeric(10),@P46 numeric(10),@P47 numeric(10),@P48 nvarchar(4000),@P49 numeric(10),@P50 varbinary(16),@P51 numeric(10),@P52 numeric(10),@P53 numeric(10),@P54 numeric(10),@P55 numeric(10),@P56 numeric(10),@P57 numeric(10),@P58 numeric(10),@P59 numeric(10),@P60 numeric(10),@P61 numeric(10),@P62 nvarchar(4000),@P63 numeric(10),@P64 varbinary(16),@P65 numeric(10),@P66 numeric(10),@P67 numeric(10),@P68 numeric(10),@P69 numeric(10),@P70 numeric(10),@P71 numeric(10),@P72 nvarchar(4000),@P73 numeric(10),@P74 varbinary(16),@P75 numeric(10),@P76 numeric(10),@P77 numeric(10),@P78 numeric(10),@P79 numeric(10),@P80 numeric(10),@P81 numeric(10),@P82 nvarchar(4000),@P83 numeric(10),@P84 varbinary(16),@P85 numeric(10),@P86 numeric(10),@P87 numeric(10),@P88 numeric(10),@P89 numeric(10),@P90 numeric(10),@P91 numeric(10),@P92 nvarchar(4000),@P93 numeric(10),@P94 varbinary(16),@P95 numeric(10),@P96 numeric(10),@P97 numeric(10),@P98 numeric(10),@P99 numeric(10),@P100 numeric(10),@P101 numeric(10),@P102 numeric(10),@P103 nvarchar(4000),@P104 numeric(10),@P105 varbinary(16),@P106 numeric(10),@P107 numeric(10),@P108 numeric(10),@P109 numeric(10),@P110 numeric(10),@P111 numeric(10),@P112 numeric(10),@P113 varbinary(16),@P114 numeric(10),@P115 numeric(10),@P116 nvarchar(4000),@P117 numeric(10),@P118 varbinary(16),@P119 numeric(10),@P120 numeric(10),@P121 numeric(10),@P122 numeric(10),@P123 numeric(10),@P124 datetime2(3),@P125 numeric(10),@P126 numeric(10),@P127 numeric(10),@P128 numeric(10),@P129 nvarchar(4000),@P130 numeric(10),@P131 varbinary(16),@P132 numeric(10),@P133 numeric(10),@P134 numeric(10),@P135 numeric(10),@P136 numeric(10),@P137 datetime2(3),@P138 datetime2(3),@P139 nvarchar(4000),@P140 numeric(10),@P141 varbinary(16),@P142 numeric(10),@P143 numeric(10),@P144 numeric(10),@P145 numeric(10),@P146 numeric(10),@P147 numeric(10),@P148 numeric(10),@P149 numeric(10),@P150 nvarchar(4000),@P151 numeric(10),@P152 varbinary(16),@P153 numeric(10),@P154 numeric(10),@P155 numeric(10),@P156 numeric(10),@P157 numeric(10),@P158 numeric(10),@P159 numeric(10),@P160 numeric(10),@P161 nvarchar(4000),@P162 numeric(10),@P163 varbinary(16),@P164 numeric(10),@P165 numeric(10),@P166 numeric(10),@P167 numeric(10),@P168 numeric(10),@P169 numeric(10),@P170 numeric(10),@P171 numeric(10),@P172 numeric(10),@P173 numeric(10),@P174 numeric(10),@P175 nvarchar(4000),@P176 numeric(10),@P177 varbinary(16),@P178 numeric(10),@P179 numeric(10),@P180 numeric(10),@P181 numeric(10),@P182 numeric(10),@P183 numeric(10),@P184 numeric(10),@P185 nvarchar(4000),@P186 numeric(10),@P187 varbinary(16),@P188 numeric(10),@P189 numeric(10),@P190 numeric(10),@P191 numeric(10),@P192 numeric(10),@P193 numeric(10),@P194 numeric(10),@P195 nvarchar(4000),@P196 numeric(10),@P197 varbinary(16),@P198 numeric(10),@P199 numeric(10),@P200 numeric(10),@P201 numeric(10),@P202 numeric(10),@P203 numeric(10),@P204 numeric(10),@P205 nvarchar(4000),@P206 numeric(10),@P207 varbinary(16),@P208 numeric(10),@P209 numeric(10),@P210 numeric(10),@P211 numeric(10),@P212 numeric(10),@P213 numeric(10),@P214 numeric(10),@P215 numeric(10),@P216 nvarchar(4000),@P217 numeric(10),@P218 varbinary(16),@P219 numeric(10),@P220 numeric(10),@P221 numeric(10),@P222 numeric(10),@P223 numeric(10),@P224 numeric(10),@P225 numeric(10),@P226 varbinary(16))INSERT INTO #tt213 WITH(TABLOCK) (_Q_001_F_000RRef, _Q_001_F_001_TYPE, _Q_001_F_001_RTRef, _Q_001_F_001_RRRef, _Q_001_F_002, _Q_001_F_003, _Q_001_F_004RRef, _Q_001_F_005, _Q_001_F_006) SELECT
  2. T43.IDRRef,
  3. T23.Fld10540_TYPE,
  4. T23.Fld10540_RTRef,
  5. T23.Fld10540_RRRef,
  6. CASE WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E4 THEN T52._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E9 THEN T53.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D4 THEN T63._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000EA THEN T64.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FD THEN T76._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000107 THEN T77._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000103 THEN T78.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D8 THEN T88.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D7 THEN T98.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D3 THEN T108.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000F8 THEN T118._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FF THEN T119.Date_Time_ ELSE CAST(NULL AS DATETIME) END,
  7. CASE WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E4 THEN T52._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E9 THEN T53.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D4 THEN T63._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000EA THEN T64.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FD THEN T76._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000107 THEN T77._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000103 THEN T78.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D8 THEN T88.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D7 THEN T98.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D3 THEN T108.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000F8 THEN T118._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FF THEN T119.Number_ ELSE CAST(NULL AS NVARCHAR(15)) END,
  8. T129._Fld1083RRef,
  9. CAST(DATEDIFF(DAY,CASE WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E4 THEN T52._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E9 THEN T53.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D4 THEN T63._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000EA THEN T64.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FD THEN T76._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000107 THEN T77._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000103 THEN T78.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D8 THEN T88.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D7 THEN T98.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D3 THEN T108.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000F8 THEN T118._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FF THEN T119.Date_Time_ ELSE CAST(NULL AS DATETIME) END,{ts '4019-03-24 23:59:59'}) AS NUMERIC(12)),
  10. CAST(SUM(T23.Fld10545Balance_) AS NUMERIC(38, 8))
  11. FROM (SELECT
  12. T24.Fld10540_TYPE AS Fld10540_TYPE,
  13. T24.Fld10540_RTRef AS Fld10540_RTRef,
  14. T24.Fld10540_RRRef AS Fld10540_RRRef,
  15. T24.Fld10538RRef AS Fld10538RRef,
  16. T24.Fld10537RRef AS Fld10537RRef,
  17. T24.Fld10539RRef AS Fld10539RRef,
  18. CAST(SUM(T24.Fld10545Balance_) AS NUMERIC(38, 8)) AS Fld10545Balance_
  19. FROM (SELECT
  20. T25._Fld10540_TYPE AS Fld10540_TYPE,
  21. T25._Fld10540_RTRef AS Fld10540_RTRef,
  22. T25._Fld10540_RRRef AS Fld10540_RRRef,
  23. T25._Fld10538RRef AS Fld10538RRef,
  24. T25._Fld10537RRef AS Fld10537RRef,
  25. T25._Fld10539RRef AS Fld10539RRef,
  26. CAST(SUM(T25._Fld10545) AS NUMERIC(33, 8)) AS Fld10545Balance_
  27. FROM dbo._AccumRgT10549 T25
  28. WHERE (((T25._Fld595 = @P1)) AND (EXISTS(SELECT
  29. 1
  30. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  31. LEFT OUTER JOIN dbo._Reference42 T26
  32. ON ((T25._Fld10538RRef = T26._IDRRef)) AND (T26._Fld595 = @P2)
  33. WHERE EXISTS(SELECT
  34. 0x01 AS Q_001_F_000_
  35. FROM dbo._Reference98 T27
  36. INNER JOIN dbo._Reference21 T28
  37. ON (((T27._Fld1685 = @P3) AND EXISTS(SELECT
  38. 0x01 AS Q_004_F_000_
  39. FROM dbo._InfoRg11709 T29
  40. WHERE ((T29._Fld595 = @P4)) AND ((T29._Fld12065RRef = T27._IDRRef) AND (T29._Fld12066RRef = T28._IDRRef)))) AND T28._IDRRef IN
  41. (SELECT
  42. T30._Reference21_IDRRef AS Q_005_F_000RRef
  43. FROM dbo._Reference21_VT782 T30
  44. INNER JOIN dbo._InfoRg9937 T31
  45. ON ((T31._Fld9939_TYPE = 0x08 AND T31._Fld9939_RTRef = 0x00000095 AND T31._Fld9939_RRRef = @P5) AND (T31._Fld9938_TYPE = T30._Fld784_TYPE AND T31._Fld9938_RTRef = T30._Fld784_RTRef AND T31._Fld9938_RRRef = T30._Fld784_RRRef))
  46. WHERE ((T30._Fld595 = @P6)) AND (T31._Fld595 = @P7)))
  47. WHERE ((T28._Fld595 = @P8)) AND ((CASE WHEN T26._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T26._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  48. 0x01 AS Q_002_F_000_
  49. FROM dbo._InfoRg11710 T32
  50. WHERE ((T32._Fld595 = @P9)) AND ((T32._Fld12072RRef = T28._IDRRef) AND (T32._Fld12073_TYPE = CASE WHEN T26._Fld12836RRef IS NOT NULL THEN 0x08 END AND T32._Fld12073_RTRef = CASE WHEN T26._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T32._Fld12073_RRRef = T26._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  51. 0x01 AS Q_003_F_000_
  52. FROM dbo._InfoRg11715 T33
  53. WHERE ((T33._Fld595 = @P10)) AND ((T33._Fld12199RRef = T28._IDRRef) AND T33._Fld12200_TYPE = CASE WHEN T26._Fld12836RRef IS NOT NULL THEN 0x08 END AND T33._Fld12200_RTRef = CASE WHEN T26._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T33._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T25._Period = @P11 AND (0x00) = 0x01 AND (T25._Fld10545 <> @P12) AND (T25._Fld10545 <> @P13))
  54. GROUP BY T25._Fld10540_TYPE,
  55. T25._Fld10540_RTRef,
  56. T25._Fld10540_RRRef,
  57. T25._Fld10538RRef,
  58. T25._Fld10537RRef,
  59. T25._Fld10539RRef
  60. HAVING (CAST(SUM(T25._Fld10545) AS NUMERIC(33, 8))) <> 0.0
  61. UNION ALL SELECT
  62. T34._Fld10540_TYPE AS Fld10540_TYPE,
  63. T34._Fld10540_RTRef AS Fld10540_RTRef,
  64. T34._Fld10540_RRRef AS Fld10540_RRRef,
  65. T34._Fld10538RRef AS Fld10538RRef,
  66. T34._Fld10537RRef AS Fld10537RRef,
  67. T34._Fld10539RRef AS Fld10539RRef,
  68. CAST(CAST(SUM(CASE WHEN T34._RecordKind = 0.0 THEN -T34._Fld10545 ELSE T34._Fld10545 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld10545Balance_
  69. FROM dbo._AccumRg10535 T34
  70. WHERE (((T34._Fld595 = @P14)) AND (EXISTS(SELECT
  71. 1
  72. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  73. LEFT OUTER JOIN dbo._Reference42 T35
  74. ON ((T34._Fld10538RRef = T35._IDRRef)) AND (T35._Fld595 = @P15)
  75. WHERE EXISTS(SELECT
  76. 0x01 AS Q_001_F_000_
  77. FROM dbo._Reference98 T36
  78. INNER JOIN dbo._Reference21 T37
  79. ON (((T36._Fld1685 = @P16) AND EXISTS(SELECT
  80. 0x01 AS Q_004_F_000_
  81. FROM dbo._InfoRg11709 T38
  82. WHERE ((T38._Fld595 = @P17)) AND ((T38._Fld12065RRef = T36._IDRRef) AND (T38._Fld12066RRef = T37._IDRRef)))) AND T37._IDRRef IN
  83. (SELECT
  84. T39._Reference21_IDRRef AS Q_005_F_000RRef
  85. FROM dbo._Reference21_VT782 T39
  86. INNER JOIN dbo._InfoRg9937 T40
  87. ON ((T40._Fld9939_TYPE = 0x08 AND T40._Fld9939_RTRef = 0x00000095 AND T40._Fld9939_RRRef = @P18) AND (T40._Fld9938_TYPE = T39._Fld784_TYPE AND T40._Fld9938_RTRef = T39._Fld784_RTRef AND T40._Fld9938_RRRef = T39._Fld784_RRRef))
  88. WHERE ((T39._Fld595 = @P19)) AND (T40._Fld595 = @P20)))
  89. WHERE ((T37._Fld595 = @P21)) AND ((CASE WHEN T35._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T35._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  90. 0x01 AS Q_002_F_000_
  91. FROM dbo._InfoRg11710 T41
  92. WHERE ((T41._Fld595 = @P22)) AND ((T41._Fld12072RRef = T37._IDRRef) AND (T41._Fld12073_TYPE = CASE WHEN T35._Fld12836RRef IS NOT NULL THEN 0x08 END AND T41._Fld12073_RTRef = CASE WHEN T35._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T41._Fld12073_RRRef = T35._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  93. 0x01 AS Q_003_F_000_
  94. FROM dbo._InfoRg11715 T42
  95. WHERE ((T42._Fld595 = @P23)) AND ((T42._Fld12199RRef = T37._IDRRef) AND T42._Fld12200_TYPE = CASE WHEN T35._Fld12836RRef IS NOT NULL THEN 0x08 END AND T42._Fld12200_RTRef = CASE WHEN T35._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T42._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T34._Period >= @P24 AND T34._Period < @P25 AND T34._Active = 0x01 AND (0x00) = 0x01)
  96. GROUP BY T34._Fld10540_TYPE,
  97. T34._Fld10540_RTRef,
  98. T34._Fld10540_RRRef,
  99. T34._Fld10538RRef,
  100. T34._Fld10537RRef,
  101. T34._Fld10539RRef
  102. HAVING (CAST(CAST(SUM(CASE WHEN T34._RecordKind = 0.0 THEN -T34._Fld10545 ELSE T34._Fld10545 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2))) <> 0.0) T24
  103. GROUP BY T24.Fld10540_TYPE,
  104. T24.Fld10540_RTRef,
  105. T24.Fld10540_RRRef,
  106. T24.Fld10538RRef,
  107. T24.Fld10537RRef,
  108. T24.Fld10539RRef
  109. HAVING (CAST(SUM(T24.Fld10545Balance_) AS NUMERIC(38, 8))) <> 0.0) T23
  110. LEFT OUTER JOIN (SELECT
  111. T44._IDRRef AS IDRRef,
  112. T44._Folder AS Folder_,
  113. T44._Fld12836RRef AS Fld12836RRef,
  114. T44._Fld595 AS Fld595_
  115. FROM dbo._Reference42 T44
  116. WHERE ((((T44._Folder = 0x00) OR EXISTS(SELECT
  117. 0x01 AS Q_001_F_000_
  118. FROM dbo._Reference98 T45
  119. INNER JOIN dbo._Reference21 T46
  120. ON (((T45._Fld1685 = @P26) AND EXISTS(SELECT
  121. 0x01 AS Q_004_F_000_
  122. FROM dbo._InfoRg11709 T47
  123. WHERE ((T47._Fld595 = @P27)) AND ((T47._Fld12065RRef = T45._IDRRef) AND (T47._Fld12066RRef = T46._IDRRef)))) AND T46._IDRRef IN
  124. (SELECT
  125. T48._Reference21_IDRRef AS Q_005_F_000RRef
  126. FROM dbo._Reference21_VT782 T48
  127. INNER JOIN dbo._InfoRg9937 T49
  128. ON ((T49._Fld9939_TYPE = 0x08 AND T49._Fld9939_RTRef = 0x00000095 AND T49._Fld9939_RRRef = @P28) AND (T49._Fld9938_TYPE = T48._Fld784_TYPE AND T49._Fld9938_RTRef = T48._Fld784_RTRef AND T49._Fld9938_RRRef = T48._Fld784_RRRef))
  129. WHERE ((T48._Fld595 = @P29)) AND (T49._Fld595 = @P30)))
  130. WHERE ((T46._Fld595 = @P31)) AND ((CASE WHEN T44._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  131. 0x01 AS Q_002_F_000_
  132. FROM dbo._InfoRg11710 T50
  133. WHERE ((T50._Fld595 = @P32)) AND ((T50._Fld12072RRef = T46._IDRRef) AND (T50._Fld12073_TYPE = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x08 END AND T50._Fld12073_RTRef = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T50._Fld12073_RRRef = T44._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  134. 0x01 AS Q_003_F_000_
  135. FROM dbo._InfoRg11715 T51
  136. WHERE ((T51._Fld595 = @P33)) AND ((T51._Fld12199RRef = T46._IDRRef) AND T51._Fld12200_TYPE = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x08 END AND T51._Fld12200_RTRef = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T51._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T44._Fld595 = @P34)) T43
  137. ON (T23.Fld10538RRef = T43.IDRRef)
  138. LEFT OUTER JOIN dbo._Document228 T52
  139. ON (T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E4 AND T23.Fld10540_RRRef = T52._IDRRef) AND (T52._Fld595 = @P35)
  140. LEFT OUTER JOIN (SELECT
  141. T54._Number COLLATE Latin1_General_CI_AS AS Number_,
  142. T54._Date_Time AS Date_Time_,
  143. T54._IDRRef AS IDRRef,
  144. T54._Fld4625RRef AS Fld4625RRef,
  145. T54._Fld595 AS Fld595_
  146. FROM dbo._Document233 T54
  147. WHERE ((EXISTS(SELECT
  148. 1
  149. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  150. LEFT OUTER JOIN dbo._Reference42 T55
  151. ON ((T54._Fld4625RRef = T55._IDRRef)) AND (T55._Fld595 = @P36)
  152. WHERE EXISTS(SELECT
  153. 0x01 AS Q_001_F_000_
  154. FROM dbo._Reference98 T56
  155. INNER JOIN dbo._Reference21 T57
  156. ON (((T56._Fld1685 = @P37) AND EXISTS(SELECT
  157. 0x01 AS Q_004_F_000_
  158. FROM dbo._InfoRg11709 T58
  159. WHERE ((T58._Fld595 = @P38)) AND ((T58._Fld12065RRef = T56._IDRRef) AND (T58._Fld12066RRef = T57._IDRRef)))) AND T57._IDRRef IN
  160. (SELECT
  161. T59._Reference21_IDRRef AS Q_005_F_000RRef
  162. FROM dbo._Reference21_VT782 T59
  163. INNER JOIN dbo._InfoRg9937 T60
  164. ON ((T60._Fld9939_TYPE = 0x08 AND T60._Fld9939_RTRef = 0x00000095 AND T60._Fld9939_RRRef = @P39) AND (T60._Fld9938_TYPE = T59._Fld784_TYPE AND T60._Fld9938_RTRef = T59._Fld784_RTRef AND T60._Fld9938_RRRef = T59._Fld784_RRRef))
  165. WHERE ((T59._Fld595 = @P40)) AND (T60._Fld595 = @P41)))
  166. WHERE ((T57._Fld595 = @P42)) AND ((CASE WHEN T55._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T55._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  167. 0x01 AS Q_002_F_000_
  168. FROM dbo._InfoRg11710 T61
  169. WHERE ((T61._Fld595 = @P43)) AND ((T61._Fld12072RRef = T57._IDRRef) AND (T61._Fld12073_TYPE = CASE WHEN T55._Fld12836RRef IS NOT NULL THEN 0x08 END AND T61._Fld12073_RTRef = CASE WHEN T55._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T61._Fld12073_RRRef = T55._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  170. 0x01 AS Q_003_F_000_
  171. FROM dbo._InfoRg11715 T62
  172. WHERE ((T62._Fld595 = @P44)) AND ((T62._Fld12199RRef = T57._IDRRef) AND T62._Fld12200_TYPE = CASE WHEN T55._Fld12836RRef IS NOT NULL THEN 0x08 END AND T62._Fld12200_RTRef = CASE WHEN T55._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T62._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T54._Fld595 = @P45)) T53
  173. ON T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E9 AND T23.Fld10540_RRRef = T53.IDRRef
  174. LEFT OUTER JOIN dbo._Document212 T63
  175. ON (T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D4 AND T23.Fld10540_RRRef = T63._IDRRef) AND (T63._Fld595 = @P46)
  176. LEFT OUTER JOIN (SELECT
  177. T65._IDRRef AS IDRRef,
  178. T65._Fld595 AS Fld595_,
  179. T65._Fld4774RRef AS Fld4774RRef,
  180. T65._Date_Time AS Date_Time_,
  181. T65._Number COLLATE Latin1_General_CI_AS AS Number_,
  182. T65._Fld4779RRef AS Fld4779RRef
  183. FROM dbo._Document234 T65
  184. WHERE ((EXISTS(SELECT
  185. 1
  186. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  187. LEFT OUTER JOIN dbo._Reference42 T66
  188. ON ((T65._Fld4774RRef = T66._IDRRef)) AND (T66._Fld595 = @P47)
  189. WHERE EXISTS(SELECT
  190. 0x01 AS Q_001_F_000_
  191. FROM dbo._Reference98 T67
  192. INNER JOIN dbo._Reference21 T68
  193. ON (((T67._Fld1685 = @P48) AND EXISTS(SELECT
  194. 0x01 AS Q_006_F_000_
  195. FROM dbo._InfoRg11709 T69
  196. WHERE ((T69._Fld595 = @P49)) AND ((T69._Fld12065RRef = T67._IDRRef) AND (T69._Fld12066RRef = T68._IDRRef)))) AND T68._IDRRef IN
  197. (SELECT
  198. T70._Reference21_IDRRef AS Q_007_F_000RRef
  199. FROM dbo._Reference21_VT782 T70
  200. INNER JOIN dbo._InfoRg9937 T71
  201. ON ((T71._Fld9939_TYPE = 0x08 AND T71._Fld9939_RTRef = 0x00000095 AND T71._Fld9939_RRRef = @P50) AND (T71._Fld9938_TYPE = T70._Fld784_TYPE AND T71._Fld9938_RTRef = T70._Fld784_RTRef AND T71._Fld9938_RRRef = T70._Fld784_RRRef))
  202. WHERE ((T70._Fld595 = @P51)) AND (T71._Fld595 = @P52)))
  203. WHERE ((T68._Fld595 = @P53)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  204. 0x01 AS Q_002_F_000_
  205. FROM dbo._InfoRg11710 T72
  206. WHERE ((T72._Fld595 = @P54)) AND ((T72._Fld12072RRef = T68._IDRRef) AND (T72._Fld12073_TYPE = 0x08 AND T72._Fld12073_RTRef = 0x0000001C AND T72._Fld12073_RRRef = T65._Fld4779RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  207. 0x01 AS Q_003_F_000_
  208. FROM dbo._InfoRg11715 T73
  209. WHERE ((T73._Fld595 = @P55)) AND ((T73._Fld12199RRef = T68._IDRRef) AND T73._Fld12200_TYPE = 0x08 AND T73._Fld12200_RTRef = 0x0000001C AND (T73._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) AND (CASE WHEN T66._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  210. 0x01 AS Q_004_F_000_
  211. FROM dbo._InfoRg11710 T74
  212. WHERE ((T74._Fld595 = @P56)) AND ((T74._Fld12072RRef = T68._IDRRef) AND (T74._Fld12073_TYPE = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x08 END AND T74._Fld12073_RTRef = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T74._Fld12073_RRRef = T66._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  213. 0x01 AS Q_005_F_000_
  214. FROM dbo._InfoRg11715 T75
  215. WHERE ((T75._Fld595 = @P57)) AND ((T75._Fld12199RRef = T68._IDRRef) AND T75._Fld12200_TYPE = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x08 END AND T75._Fld12200_RTRef = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T75._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T65._Fld595 = @P58)) T64
  216. ON T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000EA AND T23.Fld10540_RRRef = T64.IDRRef
  217. LEFT OUTER JOIN dbo._Document253 T76
  218. ON (T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FD AND T23.Fld10540_RRRef = T76._IDRRef) AND (T76._Fld595 = @P59)
  219. LEFT OUTER JOIN dbo._Document263 T77
  220. ON (T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000107 AND T23.Fld10540_RRRef = T77._IDRRef) AND (T77._Fld595 = @P60)
  221. LEFT OUTER JOIN (SELECT
  222. T79._Fld6139RRef AS Fld6139RRef,
  223. T79._Fld595 AS Fld595_,
  224. T79._Number COLLATE Latin1_General_CI_AS AS Number_,
  225. T79._IDRRef AS IDRRef,
  226. T79._Date_Time AS Date_Time_
  227. FROM dbo._Document259 T79
  228. WHERE ((EXISTS(SELECT
  229. 1
  230. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  231. LEFT OUTER JOIN dbo._Reference42 T80
  232. ON ((T79._Fld6139RRef = T80._IDRRef)) AND (T80._Fld595 = @P61)
  233. WHERE EXISTS(SELECT
  234. 0x01 AS Q_001_F_000_
  235. FROM dbo._Reference98 T81
  236. INNER JOIN dbo._Reference21 T82
  237. ON (((T81._Fld1685 = @P62) AND EXISTS(SELECT
  238. 0x01 AS Q_004_F_000_
  239. FROM dbo._InfoRg11709 T83
  240. WHERE ((T83._Fld595 = @P63)) AND ((T83._Fld12065RRef = T81._IDRRef) AND (T83._Fld12066RRef = T82._IDRRef)))) AND T82._IDRRef IN
  241. (SELECT
  242. T84._Reference21_IDRRef AS Q_005_F_000RRef
  243. FROM dbo._Reference21_VT782 T84
  244. INNER JOIN dbo._InfoRg9937 T85
  245. ON ((T85._Fld9939_TYPE = 0x08 AND T85._Fld9939_RTRef = 0x00000095 AND T85._Fld9939_RRRef = @P64) AND (T85._Fld9938_TYPE = T84._Fld784_TYPE AND T85._Fld9938_RTRef = T84._Fld784_RTRef AND T85._Fld9938_RRRef = T84._Fld784_RRRef))
  246. WHERE ((T84._Fld595 = @P65)) AND (T85._Fld595 = @P66)))
  247. WHERE ((T82._Fld595 = @P67)) AND ((CASE WHEN T80._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  248. 0x01 AS Q_002_F_000_
  249. FROM dbo._InfoRg11710 T86
  250. WHERE ((T86._Fld595 = @P68)) AND ((T86._Fld12072RRef = T82._IDRRef) AND (T86._Fld12073_TYPE = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x08 END AND T86._Fld12073_RTRef = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T86._Fld12073_RRRef = T80._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  251. 0x01 AS Q_003_F_000_
  252. FROM dbo._InfoRg11715 T87
  253. WHERE ((T87._Fld595 = @P69)) AND ((T87._Fld12199RRef = T82._IDRRef) AND T87._Fld12200_TYPE = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x08 END AND T87._Fld12200_RTRef = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T87._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T79._Fld595 = @P70)) T78
  254. ON T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000103 AND T23.Fld10540_RRRef = T78.IDRRef
  255. LEFT OUTER JOIN (SELECT
  256. T89._Fld3845RRef AS Fld3845RRef,
  257. T89._IDRRef AS IDRRef,
  258. T89._Date_Time AS Date_Time_,
  259. T89._Number COLLATE Latin1_General_CI_AS AS Number_,
  260. T89._Fld595 AS Fld595_
  261. FROM dbo._Document216 T89
  262. WHERE ((EXISTS(SELECT
  263. 1
  264. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  265. LEFT OUTER JOIN dbo._Reference42 T90
  266. ON ((T89._Fld3845RRef = T90._IDRRef)) AND (T90._Fld595 = @P71)
  267. WHERE EXISTS(SELECT
  268. 0x01 AS Q_001_F_000_
  269. FROM dbo._Reference98 T91
  270. INNER JOIN dbo._Reference21 T92
  271. ON (((T91._Fld1685 = @P72) AND EXISTS(SELECT
  272. 0x01 AS Q_004_F_000_
  273. FROM dbo._InfoRg11709 T93
  274. WHERE ((T93._Fld595 = @P73)) AND ((T93._Fld12065RRef = T91._IDRRef) AND (T93._Fld12066RRef = T92._IDRRef)))) AND T92._IDRRef IN
  275. (SELECT
  276. T94._Reference21_IDRRef AS Q_005_F_000RRef
  277. FROM dbo._Reference21_VT782 T94
  278. INNER JOIN dbo._InfoRg9937 T95
  279. ON ((T95._Fld9939_TYPE = 0x08 AND T95._Fld9939_RTRef = 0x00000095 AND T95._Fld9939_RRRef = @P74) AND (T95._Fld9938_TYPE = T94._Fld784_TYPE AND T95._Fld9938_RTRef = T94._Fld784_RTRef AND T95._Fld9938_RRRef = T94._Fld784_RRRef))
  280. WHERE ((T94._Fld595 = @P75)) AND (T95._Fld595 = @P76)))
  281. WHERE ((T92._Fld595 = @P77)) AND ((CASE WHEN T90._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T90._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  282. 0x01 AS Q_002_F_000_
  283. FROM dbo._InfoRg11710 T96
  284. WHERE ((T96._Fld595 = @P78)) AND ((T96._Fld12072RRef = T92._IDRRef) AND (T96._Fld12073_TYPE = CASE WHEN T90._Fld12836RRef IS NOT NULL THEN 0x08 END AND T96._Fld12073_RTRef = CASE WHEN T90._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T96._Fld12073_RRRef = T90._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  285. 0x01 AS Q_003_F_000_
  286. FROM dbo._InfoRg11715 T97
  287. WHERE ((T97._Fld595 = @P79)) AND ((T97._Fld12199RRef = T92._IDRRef) AND T97._Fld12200_TYPE = CASE WHEN T90._Fld12836RRef IS NOT NULL THEN 0x08 END AND T97._Fld12200_RTRef = CASE WHEN T90._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T97._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T89._Fld595 = @P80)) T88
  288. ON T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D8 AND T23.Fld10540_RRRef = T88.IDRRef
  289. LEFT OUTER JOIN (SELECT
  290. T99._IDRRef AS IDRRef,
  291. T99._Fld595 AS Fld595_,
  292. T99._Fld3734RRef AS Fld3734RRef,
  293. T99._Date_Time AS Date_Time_,
  294. T99._Number COLLATE Latin1_General_CI_AS AS Number_
  295. FROM dbo._Document215 T99
  296. WHERE ((EXISTS(SELECT
  297. 1
  298. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  299. LEFT OUTER JOIN dbo._Reference42 T100
  300. ON ((T99._Fld3734RRef = T100._IDRRef)) AND (T100._Fld595 = @P81)
  301. WHERE EXISTS(SELECT
  302. 0x01 AS Q_001_F_000_
  303. FROM dbo._Reference98 T101
  304. INNER JOIN dbo._Reference21 T102
  305. ON (((T101._Fld1685 = @P82) AND EXISTS(SELECT
  306. 0x01 AS Q_004_F_000_
  307. FROM dbo._InfoRg11709 T103
  308. WHERE ((T103._Fld595 = @P83)) AND ((T103._Fld12065RRef = T101._IDRRef) AND (T103._Fld12066RRef = T102._IDRRef)))) AND T102._IDRRef IN
  309. (SELECT
  310. T104._Reference21_IDRRef AS Q_005_F_000RRef
  311. FROM dbo._Reference21_VT782 T104
  312. INNER JOIN dbo._InfoRg9937 T105
  313. ON ((T105._Fld9939_TYPE = 0x08 AND T105._Fld9939_RTRef = 0x00000095 AND T105._Fld9939_RRRef = @P84) AND (T105._Fld9938_TYPE = T104._Fld784_TYPE AND T105._Fld9938_RTRef = T104._Fld784_RTRef AND T105._Fld9938_RRRef = T104._Fld784_RRRef))
  314. WHERE ((T104._Fld595 = @P85)) AND (T105._Fld595 = @P86)))
  315. WHERE ((T102._Fld595 = @P87)) AND ((CASE WHEN T100._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T100._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  316. 0x01 AS Q_002_F_000_
  317. FROM dbo._InfoRg11710 T106
  318. WHERE ((T106._Fld595 = @P88)) AND ((T106._Fld12072RRef = T102._IDRRef) AND (T106._Fld12073_TYPE = CASE WHEN T100._Fld12836RRef IS NOT NULL THEN 0x08 END AND T106._Fld12073_RTRef = CASE WHEN T100._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T106._Fld12073_RRRef = T100._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  319. 0x01 AS Q_003_F_000_
  320. FROM dbo._InfoRg11715 T107
  321. WHERE ((T107._Fld595 = @P89)) AND ((T107._Fld12199RRef = T102._IDRRef) AND T107._Fld12200_TYPE = CASE WHEN T100._Fld12836RRef IS NOT NULL THEN 0x08 END AND T107._Fld12200_RTRef = CASE WHEN T100._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T107._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T99._Fld595 = @P90)) T98
  322. ON T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D7 AND T23.Fld10540_RRRef = T98.IDRRef
  323. LEFT OUTER JOIN (SELECT
  324. T109._Fld3438RRef AS Fld3438RRef,
  325. T109._IDRRef AS IDRRef,
  326. T109._Number COLLATE Latin1_General_CI_AS AS Number_,
  327. T109._Fld595 AS Fld595_,
  328. T109._Date_Time AS Date_Time_
  329. FROM dbo._Document211 T109
  330. WHERE ((EXISTS(SELECT
  331. 1
  332. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  333. LEFT OUTER JOIN dbo._Reference42 T110
  334. ON ((T109._Fld3438RRef = T110._IDRRef)) AND (T110._Fld595 = @P91)
  335. WHERE EXISTS(SELECT
  336. 0x01 AS Q_001_F_000_
  337. FROM dbo._Reference98 T111
  338. INNER JOIN dbo._Reference21 T112
  339. ON (((T111._Fld1685 = @P92) AND EXISTS(SELECT
  340. 0x01 AS Q_004_F_000_
  341. FROM dbo._InfoRg11709 T113
  342. WHERE ((T113._Fld595 = @P93)) AND ((T113._Fld12065RRef = T111._IDRRef) AND (T113._Fld12066RRef = T112._IDRRef)))) AND T112._IDRRef IN
  343. (SELECT
  344. T114._Reference21_IDRRef AS Q_005_F_000RRef
  345. FROM dbo._Reference21_VT782 T114
  346. INNER JOIN dbo._InfoRg9937 T115
  347. ON ((T115._Fld9939_TYPE = 0x08 AND T115._Fld9939_RTRef = 0x00000095 AND T115._Fld9939_RRRef = @P94) AND (T115._Fld9938_TYPE = T114._Fld784_TYPE AND T115._Fld9938_RTRef = T114._Fld784_RTRef AND T115._Fld9938_RRRef = T114._Fld784_RRRef))
  348. WHERE ((T114._Fld595 = @P95)) AND (T115._Fld595 = @P96)))
  349. WHERE ((T112._Fld595 = @P97)) AND ((CASE WHEN T110._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T110._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  350. 0x01 AS Q_002_F_000_
  351. FROM dbo._InfoRg11710 T116
  352. WHERE ((T116._Fld595 = @P98)) AND ((T116._Fld12072RRef = T112._IDRRef) AND (T116._Fld12073_TYPE = CASE WHEN T110._Fld12836RRef IS NOT NULL THEN 0x08 END AND T116._Fld12073_RTRef = CASE WHEN T110._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T116._Fld12073_RRRef = T110._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  353. 0x01 AS Q_003_F_000_
  354. FROM dbo._InfoRg11715 T117
  355. WHERE ((T117._Fld595 = @P99)) AND ((T117._Fld12199RRef = T112._IDRRef) AND T117._Fld12200_TYPE = CASE WHEN T110._Fld12836RRef IS NOT NULL THEN 0x08 END AND T117._Fld12200_RTRef = CASE WHEN T110._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T117._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T109._Fld595 = @P100)) T108
  356. ON T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D3 AND T23.Fld10540_RRRef = T108.IDRRef
  357. LEFT OUTER JOIN dbo._Document248 T118
  358. ON (T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000F8 AND T23.Fld10540_RRRef = T118._IDRRef) AND (T118._Fld595 = @P101)
  359. LEFT OUTER JOIN (SELECT
  360. T120._Number COLLATE Latin1_General_CI_AS AS Number_,
  361. T120._Date_Time AS Date_Time_,
  362. T120._Fld5855RRef AS Fld5855RRef,
  363. T120._IDRRef AS IDRRef,
  364. T120._Fld595 AS Fld595_
  365. FROM dbo._Document255 T120
  366. WHERE ((EXISTS(SELECT
  367. 1
  368. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  369. LEFT OUTER JOIN dbo._Reference42 T121
  370. ON ((T120._Fld5855RRef = T121._IDRRef)) AND (T121._Fld595 = @P102)
  371. WHERE EXISTS(SELECT
  372. 0x01 AS Q_001_F_000_
  373. FROM dbo._Reference98 T122
  374. INNER JOIN dbo._Reference21 T123
  375. ON (((T122._Fld1685 = @P103) AND EXISTS(SELECT
  376. 0x01 AS Q_004_F_000_
  377. FROM dbo._InfoRg11709 T124
  378. WHERE ((T124._Fld595 = @P104)) AND ((T124._Fld12065RRef = T122._IDRRef) AND (T124._Fld12066RRef = T123._IDRRef)))) AND T123._IDRRef IN
  379. (SELECT
  380. T125._Reference21_IDRRef AS Q_005_F_000RRef
  381. FROM dbo._Reference21_VT782 T125
  382. INNER JOIN dbo._InfoRg9937 T126
  383. ON ((T126._Fld9939_TYPE = 0x08 AND T126._Fld9939_RTRef = 0x00000095 AND T126._Fld9939_RRRef = @P105) AND (T126._Fld9938_TYPE = T125._Fld784_TYPE AND T126._Fld9938_RTRef = T125._Fld784_RTRef AND T126._Fld9938_RRRef = T125._Fld784_RRRef))
  384. WHERE ((T125._Fld595 = @P106)) AND (T126._Fld595 = @P107)))
  385. WHERE ((T123._Fld595 = @P108)) AND ((CASE WHEN T121._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T121._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  386. 0x01 AS Q_002_F_000_
  387. FROM dbo._InfoRg11710 T127
  388. WHERE ((T127._Fld595 = @P109)) AND ((T127._Fld12072RRef = T123._IDRRef) AND (T127._Fld12073_TYPE = CASE WHEN T121._Fld12836RRef IS NOT NULL THEN 0x08 END AND T127._Fld12073_RTRef = CASE WHEN T121._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T127._Fld12073_RRRef = T121._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  389. 0x01 AS Q_003_F_000_
  390. FROM dbo._InfoRg11715 T128
  391. WHERE ((T128._Fld595 = @P110)) AND ((T128._Fld12199RRef = T123._IDRRef) AND T128._Fld12200_TYPE = CASE WHEN T121._Fld12836RRef IS NOT NULL THEN 0x08 END AND T128._Fld12200_RTRef = CASE WHEN T121._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T128._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T120._Fld595 = @P111)) T119
  392. ON T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FF AND T23.Fld10540_RRRef = T119.IDRRef
  393. LEFT OUTER JOIN dbo._Reference43 T129
  394. ON (T23.Fld10539RRef = T129._IDRRef) AND (T129._Fld595 = @P112)
  395. WHERE (T23.Fld10540_TYPE <> 0x01) AND (T23.Fld10537RRef = @P113)
  396. GROUP BY T23.Fld10540_TYPE,
  397. T23.Fld10540_RTRef,
  398. T23.Fld10540_RRRef,
  399. CASE WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E4 THEN T52._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E9 THEN T53.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D4 THEN T63._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000EA THEN T64.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FD THEN T76._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000107 THEN T77._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000103 THEN T78.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D8 THEN T88.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D7 THEN T98.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D3 THEN T108.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000F8 THEN T118._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FF THEN T119.Date_Time_ ELSE CAST(NULL AS DATETIME) END,
  400. CASE WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E4 THEN T52._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E9 THEN T53.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D4 THEN T63._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000EA THEN T64.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FD THEN T76._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000107 THEN T77._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000103 THEN T78.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D8 THEN T88.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D7 THEN T98.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D3 THEN T108.Number_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000F8 THEN T118._Number WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FF THEN T119.Number_ ELSE CAST(NULL AS NVARCHAR(15)) END,
  401. T129._Fld1083RRef,
  402. CAST(DATEDIFF(DAY,CASE WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E4 THEN T52._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000E9 THEN T53.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D4 THEN T63._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000EA THEN T64.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FD THEN T76._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000107 THEN T77._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x00000103 THEN T78.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D8 THEN T88.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D7 THEN T98.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000D3 THEN T108.Date_Time_ WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000F8 THEN T118._Date_Time WHEN T23.Fld10540_TYPE = 0x08 AND T23.Fld10540_RTRef = 0x000000FF THEN T119.Date_Time_ ELSE CAST(NULL AS DATETIME) END,{ts '4019-03-24 23:59:59'}) AS NUMERIC(12)),
  403. T43.IDRRef
  404. UNION ALL SELECT
  405. T150.IDRRef,
  406. T130.Fld10332_TYPE,
  407. T130.Fld10332_RTRef,
  408. T130.Fld10332_RRRef,
  409. CASE WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000E4 THEN T159._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000E9 THEN T160.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D4 THEN T170._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000EA THEN T171.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000FD THEN T183._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x00000107 THEN T184._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x00000103 THEN T185.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D8 THEN T195.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D7 THEN T205.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D3 THEN T215.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000F8 THEN T225._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000FF THEN T226.Date_Time_ ELSE CAST(NULL AS DATETIME) END,
  410. CASE WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000E4 THEN T159._Number WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000E9 THEN T160.Number_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D4 THEN T170._Number WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000EA THEN T171.Number_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000FD THEN T183._Number WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x00000107 THEN T184._Number WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x00000103 THEN T185.Number_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D8 THEN T195.Number_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D7 THEN T205.Number_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D3 THEN T215.Number_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000F8 THEN T225._Number WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000FF THEN T226.Number_ ELSE CAST(NULL AS NVARCHAR(15)) END,
  411. T236._Fld1083RRef,
  412. CAST(DATEDIFF(DAY,CASE WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000E4 THEN T159._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000E9 THEN T160.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D4 THEN T170._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000EA THEN T171.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000FD THEN T183._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x00000107 THEN T184._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x00000103 THEN T185.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D8 THEN T195.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D7 THEN T205.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000D3 THEN T215.Date_Time_ WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000F8 THEN T225._Date_Time WHEN T130.Fld10332_TYPE = 0x08 AND T130.Fld10332_RTRef = 0x000000FF THEN T226.Date_Time_ ELSE CAST(NULL AS DATETIME) END,{ts '4019-03-24 23:59:59'}) AS NUMERIC(12)),
  413. CAST(SUM(T130.Fld10335Balance_) AS NUMERIC(38, 8))
  414. FROM (SELECT
  415. T131.Fld10332_TYPE AS Fld10332_TYPE,
  416. T131.Fld10332_RTRef AS Fld10332_RTRef,
  417. T131.Fld10332_RRRef AS Fld10332_RRRef,
  418. T131.Fld10329RRef AS Fld10329RRef,
  419. T131.Fld10331RRef AS Fld10331RRef,
  420. T131.Fld10330RRef AS Fld10330RRef,
  421. CAST(SUM(T131.Fld10335Balance_) AS NUMERIC(38, 8)) AS Fld10335Balance_
  422. FROM (SELECT
  423. T132._Fld10332_TYPE AS Fld10332_TYPE,
  424. T132._Fld10332_RTRef AS Fld10332_RTRef,
  425. T132._Fld10332_RRRef AS Fld10332_RRRef,
  426. T132._Fld10329RRef AS Fld10329RRef,
  427. T132._Fld10331RRef AS Fld10331RRef,
  428. T132._Fld10330RRef AS Fld10330RRef,
  429. CAST(SUM(T132._Fld10335) AS NUMERIC(33, 8)) AS Fld10335Balance_
  430. FROM dbo._AccumRgT10337 T132
  431. WHERE (((T132._Fld595 = @P114)) AND (EXISTS(SELECT
  432. 1
  433. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  434. LEFT OUTER JOIN dbo._Reference42 T133
  435. ON ((T132._Fld10330RRef = T133._IDRRef)) AND (T133._Fld595 = @P115)
  436. WHERE EXISTS(SELECT
  437. 0x01 AS Q_001_F_000_
  438. FROM dbo._Reference98 T134
  439. INNER JOIN dbo._Reference21 T135
  440. ON (((T134._Fld1685 = @P116) AND EXISTS(SELECT
  441. 0x01 AS Q_004_F_000_
  442. FROM dbo._InfoRg11709 T136
  443. WHERE ((T136._Fld595 = @P117)) AND ((T136._Fld12065RRef = T134._IDRRef) AND (T136._Fld12066RRef = T135._IDRRef)))) AND T135._IDRRef IN
  444. (SELECT
  445. T137._Reference21_IDRRef AS Q_005_F_000RRef
  446. FROM dbo._Reference21_VT782 T137
  447. INNER JOIN dbo._InfoRg9937 T138
  448. ON ((T138._Fld9939_TYPE = 0x08 AND T138._Fld9939_RTRef = 0x00000095 AND T138._Fld9939_RRRef = @P118) AND (T138._Fld9938_TYPE = T137._Fld784_TYPE AND T138._Fld9938_RTRef = T137._Fld784_RTRef AND T138._Fld9938_RRRef = T137._Fld784_RRRef))
  449. WHERE ((T137._Fld595 = @P119)) AND (T138._Fld595 = @P120)))
  450. WHERE ((T135._Fld595 = @P121)) AND ((CASE WHEN T133._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T133._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  451. 0x01 AS Q_002_F_000_
  452. FROM dbo._InfoRg11710 T139
  453. WHERE ((T139._Fld595 = @P122)) AND ((T139._Fld12072RRef = T135._IDRRef) AND (T139._Fld12073_TYPE = CASE WHEN T133._Fld12836RRef IS NOT NULL THEN 0x08 END AND T139._Fld12073_RTRef = CASE WHEN T133._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T139._Fld12073_RRRef = T133._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  454. 0x01 AS Q_003_F_000_
  455. FROM dbo._InfoRg11715 T140
  456. WHERE ((T140._Fld595 = @P123)) AND ((T140._Fld12199RRef = T135._IDRRef) AND T140._Fld12200_TYPE = CASE WHEN T133._Fld12836RRef IS NOT NULL THEN 0x08 END AND T140._Fld12200_RTRef = CASE WHEN T133._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T140._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T132._Period = @P124 AND (0x00) = 0x01 AND (T132._Fld10335 <> @P125) AND (T132._Fld10335 <> @P126))
  457. GROUP BY T132._Fld10332_TYPE,
  458. T132._Fld10332_RTRef,
  459. T132._Fld10332_RRRef,
  460. T132._Fld10329RRef,
  461. T132._Fld10331RRef,
  462. T132._Fld10330RRef
  463. HAVING (CAST(SUM(T132._Fld10335) AS NUMERIC(33, 8))) <> 0.0
  464. UNION ALL SELECT
  465. T141._Fld10332_TYPE AS Fld10332_TYPE,
  466. T141._Fld10332_RTRef AS Fld10332_RTRef,
  467. T141._Fld10332_RRRef AS Fld10332_RRRef,
  468. T141._Fld10329RRef AS Fld10329RRef,
  469. T141._Fld10331RRef AS Fld10331RRef,
  470. T141._Fld10330RRef AS Fld10330RRef,
  471. CAST(CAST(SUM(CASE WHEN T141._RecordKind = 0.0 THEN -T141._Fld10335 ELSE T141._Fld10335 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld10335Balance_
  472. FROM dbo._AccumRg10327 T141
  473. WHERE (((T141._Fld595 = @P127)) AND (EXISTS(SELECT
  474. 1
  475. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  476. LEFT OUTER JOIN dbo._Reference42 T142
  477. ON ((T141._Fld10330RRef = T142._IDRRef)) AND (T142._Fld595 = @P128)
  478. WHERE EXISTS(SELECT
  479. 0x01 AS Q_001_F_000_
  480. FROM dbo._Reference98 T143
  481. INNER JOIN dbo._Reference21 T144
  482. ON (((T143._Fld1685 = @P129) AND EXISTS(SELECT
  483. 0x01 AS Q_004_F_000_
  484. FROM dbo._InfoRg11709 T145
  485. WHERE ((T145._Fld595 = @P130)) AND ((T145._Fld12065RRef = T143._IDRRef) AND (T145._Fld12066RRef = T144._IDRRef)))) AND T144._IDRRef IN
  486. (SELECT
  487. T146._Reference21_IDRRef AS Q_005_F_000RRef
  488. FROM dbo._Reference21_VT782 T146
  489. INNER JOIN dbo._InfoRg9937 T147
  490. ON ((T147._Fld9939_TYPE = 0x08 AND T147._Fld9939_RTRef = 0x00000095 AND T147._Fld9939_RRRef = @P131) AND (T147._Fld9938_TYPE = T146._Fld784_TYPE AND T147._Fld9938_RTRef = T146._Fld784_RTRef AND T147._Fld9938_RRRef = T146._Fld784_RRRef))
  491. WHERE ((T146._Fld595 = @P132)) AND (T147._Fld595 = @P133)))
  492. WHERE ((T144._Fld595 = @P134)) AND ((CASE WHEN T142._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T142._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  493. 0x01 AS Q_002_F_000_
  494. FROM dbo._InfoRg11710 T148
  495. WHERE ((T148._Fld595 = @P135)) AND ((T148._Fld12072RRef = T144._IDRRef) AND (T148._Fld12073_TYPE = CASE WHEN T142._Fld12836RRef IS NOT NULL THEN 0x08 END AND T148._Fld12073_RTRef = CASE WHEN T142._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T148._Fld12073_RRRef = T142._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  496. 0x01 AS Q_003_F_000_
  497. FROM dbo._InfoRg11715 T149
  498. WHERE ((T149._Fld595 = @P136)) AND ((T149._Fld12199RRef = T144._IDRRef) AND T149._Fld12200_TYPE = CASE WHEN T142._Fld12836RRef IS NOT NULL THEN 0x08 END AND T149._Fld12200_RTRef = CASE WHEN T142._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T149._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T141._Period >= @P137 AND T141._Period < @P138 AND T141._Active = 0x01 AND (0x00) = 0x01)
  499. GROUP BY T141._Fld10332
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement