Advertisement
bytecoded

TempDB Query Top 1 (SQL)

Mar 23rd, 2019
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 33.87 KB | None | 0 0
  1. (@P1 numeric(10),@P2 varbinary(16),@P3 varbinary(16),@P4 numeric(10),@P5 nvarchar(4000),@P6 numeric(10),@P7 varbinary(16),@P8 numeric(10),@P9 numeric(10),@P10 numeric(10),@P11 numeric(10),@P12 numeric(10),@P13 datetime2(3),@P14 varbinary(16),@P15 varbinary(16),@P16 numeric(10),@P17 numeric(10),@P18 numeric(10),@P19 datetime2(3),@P20 varbinary(16),@P21 varbinary(16),@P22 numeric(10),@P23 numeric(10),@P24 numeric(10),@P25 nvarchar(4000),@P26 numeric(10),@P27 varbinary(16),@P28 numeric(10),@P29 numeric(10),@P30 numeric(10),@P31 numeric(10),@P32 numeric(10),@P33 datetime2(3),@P34 datetime2(3),@P35 varbinary(16),@P36 varbinary(16),@P37 numeric(10),@P38 datetime2(3),@P39 datetime2(3),@P40 varbinary(16),@P41 varbinary(16),@P42 numeric(10),@P43 varbinary(16),@P44 varbinary(16),@P45 varbinary(16),@P46 numeric(10),@P47 datetime2(3),@P48 varbinary(16),@P49 varbinary(16),@P50 numeric(10),@P51 numeric(10),@P52 datetime2(3),@P53 datetime2(3),@P54 varbinary(16),@P55 varbinary(16),@P56 numeric(10),@P57 varbinary(16),@P58 varbinary(16),@P59 numeric(10),@P60 numeric(10),@P61 nvarchar(4000),@P62 numeric(10),@P63 varbinary(16),@P64 numeric(10),@P65 numeric(10),@P66 numeric(10),@P67 numeric(10),@P68 numeric(10),@P69 numeric(10),@P70 numeric(10),@P71 nvarchar(4000),@P72 numeric(10),@P73 varbinary(16),@P74 numeric(10),@P75 numeric(10),@P76 numeric(10),@P77 numeric(10),@P78 numeric(10),@P79 numeric(10),@P80 numeric(10),@P81 numeric(10),@P82 numeric(10),@P83 numeric(10),@P84 numeric(10),@P85 datetime2(3),@P86 varbinary(16),@P87 varbinary(16),@P88 numeric(10),@P89 numeric(10),@P90 numeric(10),@P91 nvarchar(4000),@P92 numeric(10),@P93 varbinary(16),@P94 numeric(10),@P95 numeric(10),@P96 numeric(10),@P97 numeric(10),@P98 numeric(10),@P99 numeric(10),@P100 numeric(10),@P101 nvarchar(4000),@P102 numeric(10),@P103 varbinary(16),@P104 numeric(10),@P105 numeric(10),@P106 numeric(10),@P107 numeric(10),@P108 numeric(10),@P109 numeric(10),@P110 numeric(10),@P111 numeric(10),@P112 numeric(10),@P113 numeric(10),@P114 numeric(10),@P115 datetime2(3),@P116 datetime2(3),@P117 varbinary(16),@P118 varbinary(16),@P119 varbinary(16),@P120 numeric(10),@P121 numeric(10),@P122 nvarchar(4000),@P123 numeric(10),@P124 varbinary(16),@P125 numeric(10),@P126 numeric(10),@P127 numeric(10),@P128 numeric(10),@P129 numeric(10),@P130 numeric(10),@P131 numeric(10),@P132 nvarchar(4000),@P133 numeric(10),@P134 varbinary(16),@P135 numeric(10),@P136 numeric(10),@P137 numeric(10),@P138 numeric(10),@P139 numeric(10),@P140 numeric(10),@P141 numeric(10),@P142 numeric(10),@P143 numeric(10),@P144 numeric(10),@P145 varbinary(16),@P146 varbinary(16),@P147 varbinary(16))INSERT INTO #tt47 WITH(TABLOCK) (_Q_001_F_000RRef, _Q_001_F_001, _Q_001_F_002RRef, _Q_001_F_003, _Q_001_F_004RRef) SELECT
  2. T1._Q_001_F_001RRef,
  3. T1._Q_001_F_002,
  4. T1._Q_001_F_003RRef,
  5. CASE WHEN (1=1) AND CASE WHEN 1=1 THEN CASE WHEN 1=1 THEN 0 ELSE 2000000000 END + 2000000000 ELSE 0 END = 2000000000 THEN CAST(SUM(ISNULL(CAST(CASE WHEN (T1._Q_001_F_000RRef = 0x00000000000000000000000000000000) THEN CAST(((CAST((CAST(T2._Q_001_F_000 AS NUMERIC(26, 2)) * CAST(T4._Q_000_F_001 AS NUMERIC(11, 6))) AS NUMERIC(29, 8)) * CAST(T1._Q_001_F_005 AS NUMERIC(8, 0))) / (T1._Q_001_F_004 * ISNULL(CAST(T4._Q_000_F_002 AS NUMERIC(10, 0)),1.0))) AS NUMERIC(15, 2)) ELSE T2._Q_001_F_000 END AS NUMERIC(33, 2)),0.0)) AS NUMERIC(38, 8)) END,
  6. T1._Q_001_F_000RRef
  7. FROM #tt45 T1 WITH(NOLOCK)
  8. LEFT OUTER JOIN #tt46 T2 WITH(NOLOCK)
  9. LEFT OUTER JOIN dbo._Reference43 T3
  10. ON (T2._Q_001_F_001RRef = T3._IDRRef) AND (T3._Fld595 = @P1)
  11. LEFT OUTER JOIN #tt44 T4 WITH(NOLOCK)
  12. ON (T3._Fld1083RRef = T4._Q_000_F_000RRef)
  13. ON CASE WHEN (T1._Q_001_F_000RRef = @P2) THEN 0x01 ELSE CASE WHEN (T1._Q_001_F_000RRef = T2._Q_001_F_001RRef) THEN 0x01 WHEN NOT (T1._Q_001_F_000RRef = T2._Q_001_F_001RRef) THEN 0x00 END END = 0x01
  14. WHERE (T1._Q_001_F_001RRef = @P3)
  15. GROUP BY T1._Q_001_F_001RRef,
  16. T1._Q_001_F_002,
  17. T1._Q_001_F_000RRef,
  18. T1._Q_001_F_003RRef
  19. UNION ALL SELECT
  20. T5._Q_001_F_001RRef,
  21. T5._Q_001_F_002,
  22. T5._Q_001_F_003RRef,
  23. CAST(SUM(ISNULL(CAST(CASE WHEN (T5._Q_001_F_000RRef = 0x00000000000000000000000000000000) THEN CAST(((CAST((CAST(T6.Fld11503Balance_ AS NUMERIC(26, 2)) * CAST(T29._Q_000_F_001 AS NUMERIC(11, 6))) AS NUMERIC(29, 8)) * CAST(T5._Q_001_F_005 AS NUMERIC(8, 0))) / (T5._Q_001_F_004 * ISNULL(CAST(T29._Q_000_F_002 AS NUMERIC(10, 0)),1.0))) AS NUMERIC(15, 2)) ELSE T6.Fld11503Balance_ END AS NUMERIC(33, 2)),0.0)) AS NUMERIC(38, 8)),
  24. T5._Q_001_F_000RRef
  25. FROM #tt45 T5 WITH(NOLOCK)
  26. LEFT OUTER JOIN (SELECT
  27. MIN(ISNULL(T7.SDBL_RLS_SIGNAL_,0x01)) AS SDBL_RLS_SIGNAL_,
  28. T7.Fld11497RRef AS Fld11497RRef,
  29. CAST(SUM(T7.Fld11503Balance_) AS NUMERIC(38, 8)) AS Fld11503Balance_
  30. FROM (SELECT
  31. MIN(T8.SDBL_RLS_SIGNAL_) AS SDBL_RLS_SIGNAL_,
  32. T8.Fld11497RRef AS Fld11497RRef,
  33. CAST(SUM(T8.Fld11503_) AS NUMERIC(33, 8)) AS Fld11503Balance_
  34. FROM (SELECT
  35. CASE WHEN (EXISTS(SELECT
  36. 1
  37. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  38. LEFT OUTER JOIN dbo._Reference42 T10
  39. ON ((T9._Fld11496RRef = T10._IDRRef)) AND (T10._Fld595 = @P4)
  40. WHERE EXISTS(SELECT
  41. 0x01 AS Q_001_F_000_
  42. FROM dbo._Reference98 T11
  43. INNER JOIN dbo._Reference21 T12
  44. ON (((T11._Fld1685 = @P5) AND EXISTS(SELECT
  45. 0x01 AS Q_004_F_000_
  46. FROM dbo._InfoRg11709 T13
  47. WHERE ((T13._Fld595 = @P6)) AND ((T13._Fld12065RRef = T11._IDRRef) AND (T13._Fld12066RRef = T12._IDRRef)))) AND T12._IDRRef IN
  48. (SELECT
  49. T14._Reference21_IDRRef AS Q_005_F_000RRef
  50. FROM dbo._Reference21_VT782 T14
  51. INNER JOIN dbo._InfoRg9937 T15
  52. ON ((T15._Fld9939_TYPE = 0x08 AND T15._Fld9939_RTRef = 0x00000095 AND T15._Fld9939_RRRef = @P7) AND (T15._Fld9938_TYPE = T14._Fld784_TYPE AND T15._Fld9938_RTRef = T14._Fld784_RTRef AND T15._Fld9938_RRRef = T14._Fld784_RRRef))
  53. WHERE ((T14._Fld595 = @P8)) AND (T15._Fld595 = @P9)))
  54. WHERE ((T12._Fld595 = @P10)) AND ((CASE WHEN T10._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T10._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  55. 0x01 AS Q_002_F_000_
  56. FROM dbo._InfoRg11710 T16
  57. WHERE ((T16._Fld595 = @P11)) AND ((T16._Fld12072RRef = T12._IDRRef) AND (T16._Fld12073_TYPE = CASE WHEN T10._Fld12836RRef IS NOT NULL THEN 0x08 END AND T16._Fld12073_RTRef = CASE WHEN T10._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T16._Fld12073_RRRef = T10._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  58. 0x01 AS Q_003_F_000_
  59. FROM dbo._InfoRg11715 T17
  60. WHERE ((T17._Fld595 = @P12)) AND ((T17._Fld12199RRef = T12._IDRRef) AND T17._Fld12200_TYPE = CASE WHEN T10._Fld12836RRef IS NOT NULL THEN 0x08 END AND T17._Fld12200_RTRef = CASE WHEN T10._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T17._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  61. T9._Fld11503 AS Fld11503_,
  62. T9._Fld595 AS Fld595_,
  63. T9._Fld11497RRef AS Fld11497RRef,
  64. T9._Fld11496RRef AS Fld11496RRef,
  65. T9._Period AS Period_,
  66. T9._Fld11494RRef AS Fld11494RRef
  67. FROM dbo._AccumRgT11507 T9
  68. WHERE (T9._Period = @P13 AND T9._Fld11494RRef = @P14 AND T9._Fld11496RRef = @P15 AND T9._Fld11503 <> @P16 AND T9._Fld11503 <> @P17) AND (T9._Fld595 = @P18)) T8
  69. WHERE T8.Period_ = @P19 AND (((T8.Fld11494RRef = @P20) AND (T8.Fld11496RRef = @P21))) AND (T8.Fld11503_ <> @P22) AND (T8.Fld11503_ <> @P23)
  70. GROUP BY T8.Fld11497RRef
  71. HAVING (CAST(SUM(T8.Fld11503_) AS NUMERIC(33, 8))) <> 0.0
  72. UNION ALL SELECT
  73. MIN(T18.SDBL_RLS_SIGNAL_) AS SDBL_RLS_SIGNAL_,
  74. T18.Fld11497RRef AS Fld11497RRef,
  75. CAST(CAST(SUM(CASE WHEN T18.RecordKind_ = 0.0 THEN -T18.Fld11503_ ELSE T18.Fld11503_ END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld11503Balance_
  76. FROM (SELECT
  77. CASE WHEN (EXISTS(SELECT
  78. 1
  79. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  80. LEFT OUTER JOIN dbo._Reference42 T20
  81. ON ((T19._Fld11496RRef = T20._IDRRef)) AND (T20._Fld595 = @P24)
  82. WHERE EXISTS(SELECT
  83. 0x01 AS Q_001_F_000_
  84. FROM dbo._Reference98 T21
  85. INNER JOIN dbo._Reference21 T22
  86. ON (((T21._Fld1685 = @P25) AND EXISTS(SELECT
  87. 0x01 AS Q_004_F_000_
  88. FROM dbo._InfoRg11709 T23
  89. WHERE ((T23._Fld595 = @P26)) AND ((T23._Fld12065RRef = T21._IDRRef) AND (T23._Fld12066RRef = T22._IDRRef)))) AND T22._IDRRef IN
  90. (SELECT
  91. T24._Reference21_IDRRef AS Q_005_F_000RRef
  92. FROM dbo._Reference21_VT782 T24
  93. INNER JOIN dbo._InfoRg9937 T25
  94. ON ((T25._Fld9939_TYPE = 0x08 AND T25._Fld9939_RTRef = 0x00000095 AND T25._Fld9939_RRRef = @P27) AND (T25._Fld9938_TYPE = T24._Fld784_TYPE AND T25._Fld9938_RTRef = T24._Fld784_RTRef AND T25._Fld9938_RRRef = T24._Fld784_RRRef))
  95. WHERE ((T24._Fld595 = @P28)) AND (T25._Fld595 = @P29)))
  96. WHERE ((T22._Fld595 = @P30)) AND ((CASE WHEN T20._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T20._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  97. 0x01 AS Q_002_F_000_
  98. FROM dbo._InfoRg11710 T26
  99. WHERE ((T26._Fld595 = @P31)) AND ((T26._Fld12072RRef = T22._IDRRef) AND (T26._Fld12073_TYPE = CASE WHEN T20._Fld12836RRef IS NOT NULL THEN 0x08 END AND T26._Fld12073_RTRef = CASE WHEN T20._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T26._Fld12073_RRRef = T20._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  100. 0x01 AS Q_003_F_000_
  101. FROM dbo._InfoRg11715 T27
  102. WHERE ((T27._Fld595 = @P32)) AND ((T27._Fld12199RRef = T22._IDRRef) AND T27._Fld12200_TYPE = CASE WHEN T20._Fld12836RRef IS NOT NULL THEN 0x08 END AND T27._Fld12200_RTRef = CASE WHEN T20._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T27._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  103. T19._RecordKind AS RecordKind_,
  104. T19._Period AS Period_,
  105. T19._Fld11494RRef AS Fld11494RRef,
  106. T19._Fld11503 AS Fld11503_,
  107. T19._Fld595 AS Fld595_,
  108. T19._Fld11497RRef AS Fld11497RRef,
  109. T19._Fld11496RRef AS Fld11496RRef,
  110. T19._Active AS Active_
  111. FROM dbo._AccumRg11493 T19
  112. WHERE (T19._Period >= @P33 AND T19._Period < @P34 AND T19._Fld11494RRef = @P35 AND T19._Fld11496RRef = @P36) AND (T19._Fld595 = @P37)) T18
  113. WHERE T18.Period_ >= @P38 AND T18.Period_ < @P39 AND T18.Active_ = 0x01 AND (((T18.Fld11494RRef = @P40) AND (T18.Fld11496RRef = @P41)))
  114. GROUP BY T18.Fld11497RRef
  115. HAVING (CAST(CAST(SUM(CASE WHEN T18.RecordKind_ = 0.0 THEN -T18.Fld11503_ ELSE T18.Fld11503_ END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2))) <> 0.0) T7
  116. GROUP BY T7.Fld11497RRef
  117. HAVING (CAST(SUM(T7.Fld11503Balance_) AS NUMERIC(38, 8))) <> 0.0) T6
  118. LEFT OUTER JOIN dbo._Reference43 T28
  119. ON (T6.Fld11497RRef = T28._IDRRef) AND (T28._Fld595 = @P42)
  120. LEFT OUTER JOIN #tt44 T29 WITH(NOLOCK)
  121. ON (T28._Fld1083RRef = T29._Q_000_F_000RRef)
  122. ON CASE WHEN (T5._Q_001_F_000RRef = @P43) THEN 0x01 ELSE CASE WHEN (T5._Q_001_F_000RRef = T6.Fld11497RRef) THEN 0x01 WHEN NOT (T5._Q_001_F_000RRef = T6.Fld11497RRef) THEN 0x00 END END = 0x01
  123. WHERE ((T5._Q_001_F_001RRef = @P44)) AND CASE WHEN (T28._IDRRef = T28._IDRRef OR T28._IDRRef IS NULL) AND (T29._Q_000_F_000RRef = T29._Q_000_F_000RRef OR T29._Q_000_F_000RRef IS NULL) AND (T5._Q_001_F_001RRef = @P45) THEN CASE WHEN ISNULL(T6.SDBL_RLS_SIGNAL_,0x01) = 0x01 THEN 0 ELSE 2000000000 END + 2000000000 ELSE 0 END = 2000000000
  124. GROUP BY T5._Q_001_F_001RRef,
  125. T5._Q_001_F_002,
  126. T5._Q_001_F_000RRef,
  127. T5._Q_001_F_003RRef
  128. UNION ALL SELECT
  129. T30._Q_001_F_001RRef,
  130. T30._Q_001_F_002,
  131. T30._Q_001_F_003RRef,
  132. CAST(SUM(ISNULL(CAST(CASE WHEN (T30._Q_001_F_000RRef = 0x00000000000000000000000000000000) THEN CAST(((CAST((CAST(T31.Fld11330Turnover_ AS NUMERIC(26, 2)) * CAST(T36._Q_000_F_001 AS NUMERIC(11, 6))) AS NUMERIC(29, 8)) * CAST(T30._Q_001_F_005 AS NUMERIC(8, 0))) / (T30._Q_001_F_004 * ISNULL(CAST(T36._Q_000_F_002 AS NUMERIC(10, 0)),1.0))) AS NUMERIC(15, 2)) ELSE T31.Fld11330Turnover_ END AS NUMERIC(33, 2)),0.0)) AS NUMERIC(38, 8)),
  133. T30._Q_001_F_000RRef
  134. FROM #tt45 T30 WITH(NOLOCK)
  135. LEFT OUTER JOIN (SELECT
  136. MIN(T32.SDBL_RLS_SIGNAL_) AS SDBL_RLS_SIGNAL_,
  137. T32.Fld11326RRef AS Fld11326RRef,
  138. CAST(SUM(T32.Fld11330Turnover_) AS NUMERIC(38, 8)) AS Fld11330Turnover_
  139. FROM (SELECT
  140. 0x01 AS SDBL_RLS_SIGNAL_,
  141. T33._Fld11326RRef AS Fld11326RRef,
  142. CAST(SUM(T33._Fld11330) AS NUMERIC(33, 8)) AS Fld11330Turnover_
  143. FROM dbo._AccumRgTn11332 T33
  144. WHERE ((T33._Fld595 = @P46)) AND (T33._Period < @P47 AND (((T33._Fld11324RRef = @P48) AND (T33._Fld11325RRef = @P49))) AND (T33._Fld11330 <> @P50))
  145. GROUP BY T33._Fld11326RRef
  146. HAVING (CAST(SUM(T33._Fld11330) AS NUMERIC(33, 8))) <> 0.0
  147. UNION ALL SELECT
  148. 0x01 AS SDBL_RLS_SIGNAL_,
  149. T34._Fld11326RRef AS Fld11326RRef,
  150. CAST(CAST(SUM(T34._Fld11330) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld11330Turnover_
  151. FROM dbo._AccumRg11323 T34
  152. WHERE ((T34._Fld595 = @P51)) AND (T34._Period >= @P52 AND T34._Period <= @P53 AND T34._Active = 0x01 AND (((T34._Fld11324RRef = @P54) AND (T34._Fld11325RRef = @P55))))
  153. GROUP BY T34._Fld11326RRef
  154. HAVING (CAST(CAST(SUM(T34._Fld11330) AS NUMERIC(27, 8)) AS NUMERIC(27, 2))) <> 0.0) T32
  155. GROUP BY T32.Fld11326RRef
  156. HAVING (CAST(SUM(T32.Fld11330Turnover_) AS NUMERIC(38, 8))) <> 0.0) T31
  157. LEFT OUTER JOIN dbo._Reference43 T35
  158. ON (T31.Fld11326RRef = T35._IDRRef) AND (T35._Fld595 = @P56)
  159. LEFT OUTER JOIN #tt44 T36 WITH(NOLOCK)
  160. ON (T35._Fld1083RRef = T36._Q_000_F_000RRef)
  161. ON CASE WHEN (T30._Q_001_F_000RRef = @P57) THEN 0x01 ELSE CASE WHEN (T30._Q_001_F_000RRef = T31.Fld11326RRef) THEN 0x01 WHEN NOT (T30._Q_001_F_000RRef = T31.Fld11326RRef) THEN 0x00 END END = 0x01
  162. WHERE (T30._Q_001_F_001RRef = @P58)
  163. GROUP BY T30._Q_001_F_001RRef,
  164. T30._Q_001_F_002,
  165. T30._Q_001_F_000RRef,
  166. T30._Q_001_F_003RRef
  167. UNION ALL SELECT
  168. T37._Q_001_F_001RRef,
  169. T37._Q_001_F_002,
  170. T37._Q_001_F_003RRef,
  171. CAST(CAST(SUM(ISNULL(CAST(CAST(((CAST((CAST(T38.Fld11255Turnover_ AS NUMERIC(26, 2)) * CAST(T92._Q_000_F_001 AS NUMERIC(11, 6))) AS NUMERIC(29, 8)) * CAST(T37._Q_001_F_005 AS NUMERIC(8, 0))) / (T37._Q_001_F_004 * ISNULL(CAST(T92._Q_000_F_002 AS NUMERIC(10, 0)),1.0))) AS NUMERIC(15, 2)) AS NUMERIC(15, 2)),0.0)) AS NUMERIC(27, 8)) AS NUMERIC(38, 8)),
  172. T37._Q_001_F_000RRef
  173. FROM #tt45 T37 WITH(NOLOCK)
  174. LEFT OUTER JOIN (SELECT
  175. MIN(ISNULL(T39.SDBL_RLS_SIGNAL_,0x01)) AS SDBL_RLS_SIGNAL_,
  176. T39.Fld11251_TYPE AS Fld11251_TYPE,
  177. T39.Fld11251_RTRef AS Fld11251_RTRef,
  178. T39.Fld11251_RRRef AS Fld11251_RRRef,
  179. CAST(SUM(T39.Fld11255Turnover_) AS NUMERIC(38, 8)) AS Fld11255Turnover_
  180. FROM (SELECT
  181. MIN(CASE WHEN ISNULL(T42.SDBL_RLS_SIGNAL_,0x01) = 0x01 AND ISNULL(T52.SDBL_RLS_SIGNAL_,0x01) = 0x01 THEN 0x01 ELSE 0x00 END) AS SDBL_RLS_SIGNAL_,
  182. T40._Fld11251_TYPE AS Fld11251_TYPE,
  183. T40._Fld11251_RTRef AS Fld11251_RTRef,
  184. T40._Fld11251_RRRef AS Fld11251_RRRef,
  185. CAST(SUM(T40._Fld11255) AS NUMERIC(33, 8)) AS Fld11255Turnover_
  186. FROM dbo._AccumRgTn11257 T40
  187. LEFT OUTER JOIN dbo._Document218 T41
  188. ON (T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000DA AND T40._Fld11251_RRRef = T41._IDRRef) AND (T41._Fld595 = @P59)
  189. LEFT OUTER JOIN (SELECT
  190. CASE WHEN (EXISTS(SELECT
  191. 1
  192. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  193. LEFT OUTER JOIN dbo._Reference42 T44
  194. ON ((T43._Fld4625RRef = T44._IDRRef)) AND (T44._Fld595 = @P60)
  195. WHERE EXISTS(SELECT
  196. 0x01 AS Q_001_F_000_
  197. FROM dbo._Reference98 T45
  198. INNER JOIN dbo._Reference21 T46
  199. ON (((T45._Fld1685 = @P61) AND EXISTS(SELECT
  200. 0x01 AS Q_004_F_000_
  201. FROM dbo._InfoRg11709 T47
  202. WHERE ((T47._Fld595 = @P62)) AND ((T47._Fld12065RRef = T45._IDRRef) AND (T47._Fld12066RRef = T46._IDRRef)))) AND T46._IDRRef IN
  203. (SELECT
  204. T48._Reference21_IDRRef AS Q_005_F_000RRef
  205. FROM dbo._Reference21_VT782 T48
  206. INNER JOIN dbo._InfoRg9937 T49
  207. ON ((T49._Fld9939_TYPE = 0x08 AND T49._Fld9939_RTRef = 0x00000095 AND T49._Fld9939_RRRef = @P63) AND (T49._Fld9938_TYPE = T48._Fld784_TYPE AND T49._Fld9938_RTRef = T48._Fld784_RTRef AND T49._Fld9938_RRRef = T48._Fld784_RRRef))
  208. WHERE ((T48._Fld595 = @P64)) AND (T49._Fld595 = @P65)))
  209. WHERE ((T46._Fld595 = @P66)) 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
  210. 0x01 AS Q_002_F_000_
  211. FROM dbo._InfoRg11710 T50
  212. WHERE ((T50._Fld595 = @P67)) 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
  213. 0x01 AS Q_003_F_000_
  214. FROM dbo._InfoRg11715 T51
  215. WHERE ((T51._Fld595 = @P68)) 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))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  216. T43._IDRRef AS IDRRef,
  217. T43._Fld4625RRef AS Fld4625RRef,
  218. T43._Fld595 AS Fld595_
  219. FROM dbo._Document233 T43
  220. WHERE (T43._Fld595 = @P69)) T42
  221. ON T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000E9 AND T40._Fld11251_RRRef = T42.IDRRef
  222. LEFT OUTER JOIN (SELECT
  223. CASE WHEN (EXISTS(SELECT
  224. 1
  225. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  226. LEFT OUTER JOIN dbo._Reference42 T54
  227. ON ((T53._Fld4774RRef = T54._IDRRef)) AND (T54._Fld595 = @P70)
  228. WHERE EXISTS(SELECT
  229. 0x01 AS Q_001_F_000_
  230. FROM dbo._Reference98 T55
  231. INNER JOIN dbo._Reference21 T56
  232. ON (((T55._Fld1685 = @P71) AND EXISTS(SELECT
  233. 0x01 AS Q_006_F_000_
  234. FROM dbo._InfoRg11709 T57
  235. WHERE ((T57._Fld595 = @P72)) AND ((T57._Fld12065RRef = T55._IDRRef) AND (T57._Fld12066RRef = T56._IDRRef)))) AND T56._IDRRef IN
  236. (SELECT
  237. T58._Reference21_IDRRef AS Q_007_F_000RRef
  238. FROM dbo._Reference21_VT782 T58
  239. INNER JOIN dbo._InfoRg9937 T59
  240. ON ((T59._Fld9939_TYPE = 0x08 AND T59._Fld9939_RTRef = 0x00000095 AND T59._Fld9939_RRRef = @P73) AND (T59._Fld9938_TYPE = T58._Fld784_TYPE AND T59._Fld9938_RTRef = T58._Fld784_RTRef AND T59._Fld9938_RRRef = T58._Fld784_RRRef))
  241. WHERE ((T58._Fld595 = @P74)) AND (T59._Fld595 = @P75)))
  242. WHERE ((T56._Fld595 = @P76)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  243. 0x01 AS Q_002_F_000_
  244. FROM dbo._InfoRg11710 T60
  245. WHERE ((T60._Fld595 = @P77)) AND ((T60._Fld12072RRef = T56._IDRRef) AND (T60._Fld12073_TYPE = 0x08 AND T60._Fld12073_RTRef = 0x0000001C AND T60._Fld12073_RRRef = T53._Fld4779RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  246. 0x01 AS Q_003_F_000_
  247. FROM dbo._InfoRg11715 T61
  248. WHERE ((T61._Fld595 = @P78)) AND ((T61._Fld12199RRef = T56._IDRRef) AND T61._Fld12200_TYPE = 0x08 AND T61._Fld12200_RTRef = 0x0000001C AND (T61._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) AND (CASE WHEN T54._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T54._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  249. 0x01 AS Q_004_F_000_
  250. FROM dbo._InfoRg11710 T62
  251. WHERE ((T62._Fld595 = @P79)) AND ((T62._Fld12072RRef = T56._IDRRef) AND (T62._Fld12073_TYPE = CASE WHEN T54._Fld12836RRef IS NOT NULL THEN 0x08 END AND T62._Fld12073_RTRef = CASE WHEN T54._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T62._Fld12073_RRRef = T54._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  252. 0x01 AS Q_005_F_000_
  253. FROM dbo._InfoRg11715 T63
  254. WHERE ((T63._Fld595 = @P80)) AND ((T63._Fld12199RRef = T56._IDRRef) AND T63._Fld12200_TYPE = CASE WHEN T54._Fld12836RRef IS NOT NULL THEN 0x08 END AND T63._Fld12200_RTRef = CASE WHEN T54._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T63._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  255. T53._IDRRef AS IDRRef,
  256. T53._Fld595 AS Fld595_,
  257. T53._Fld4774RRef AS Fld4774RRef,
  258. T53._Fld4779RRef AS Fld4779RRef
  259. FROM dbo._Document234 T53
  260. WHERE (T53._Fld595 = @P81)) T52
  261. ON T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000EA AND T40._Fld11251_RRRef = T52.IDRRef
  262. LEFT OUTER JOIN dbo._Document286 T64
  263. ON (T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x0000011E AND T40._Fld11251_RRRef = T64._IDRRef) AND (T64._Fld595 = @P82)
  264. LEFT OUTER JOIN dbo._Document199 T65
  265. ON (T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000C7 AND T40._Fld11251_RRRef = T65._IDRRef) AND (T65._Fld595 = @P83)
  266. WHERE ((T40._Fld595 = @P84)) AND (T40._Period < @P85 AND (((T40._Fld11246RRef = @P86) AND (CASE WHEN T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000DA THEN T41._Fld4083RRef WHEN T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000E9 THEN T42.Fld4625RRef WHEN T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000EA THEN T52.Fld4774RRef WHEN T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x0000011E THEN T64._Fld7289RRef WHEN T40._Fld11251_TYPE = 0x08 AND T40._Fld11251_RTRef = 0x000000C7 THEN T65._Fld2840RRef ELSE CAST(NULL AS BINARY(16)) END = @P87))) AND (T40._Fld11255 <> @P88))
  267. GROUP BY T40._Fld11251_TYPE,
  268. T40._Fld11251_RTRef,
  269. T40._Fld11251_RRRef
  270. HAVING (CAST(SUM(T40._Fld11255) AS NUMERIC(33, 8))) <> 0.0
  271. UNION ALL SELECT
  272. MIN(CASE WHEN ISNULL(T68.SDBL_RLS_SIGNAL_,0x01) = 0x01 AND ISNULL(T78.SDBL_RLS_SIGNAL_,0x01) = 0x01 THEN 0x01 ELSE 0x00 END) AS SDBL_RLS_SIGNAL_,
  273. T66._Fld11251_TYPE AS Fld11251_TYPE,
  274. T66._Fld11251_RTRef AS Fld11251_RTRef,
  275. T66._Fld11251_RRRef AS Fld11251_RRRef,
  276. CAST(CAST(SUM(T66._Fld11255) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld11255Turnover_
  277. FROM dbo._AccumRg11245 T66
  278. LEFT OUTER JOIN dbo._Document218 T67
  279. ON (T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000DA AND T66._Fld11251_RRRef = T67._IDRRef) AND (T67._Fld595 = @P89)
  280. LEFT OUTER JOIN (SELECT
  281. CASE WHEN (EXISTS(SELECT
  282. 1
  283. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  284. LEFT OUTER JOIN dbo._Reference42 T70
  285. ON ((T69._Fld4625RRef = T70._IDRRef)) AND (T70._Fld595 = @P90)
  286. WHERE EXISTS(SELECT
  287. 0x01 AS Q_001_F_000_
  288. FROM dbo._Reference98 T71
  289. INNER JOIN dbo._Reference21 T72
  290. ON (((T71._Fld1685 = @P91) AND EXISTS(SELECT
  291. 0x01 AS Q_004_F_000_
  292. FROM dbo._InfoRg11709 T73
  293. WHERE ((T73._Fld595 = @P92)) AND ((T73._Fld12065RRef = T71._IDRRef) AND (T73._Fld12066RRef = T72._IDRRef)))) AND T72._IDRRef IN
  294. (SELECT
  295. T74._Reference21_IDRRef AS Q_005_F_000RRef
  296. FROM dbo._Reference21_VT782 T74
  297. INNER JOIN dbo._InfoRg9937 T75
  298. ON ((T75._Fld9939_TYPE = 0x08 AND T75._Fld9939_RTRef = 0x00000095 AND T75._Fld9939_RRRef = @P93) AND (T75._Fld9938_TYPE = T74._Fld784_TYPE AND T75._Fld9938_RTRef = T74._Fld784_RTRef AND T75._Fld9938_RRRef = T74._Fld784_RRRef))
  299. WHERE ((T74._Fld595 = @P94)) AND (T75._Fld595 = @P95)))
  300. WHERE ((T72._Fld595 = @P96)) AND ((CASE WHEN T70._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T70._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  301. 0x01 AS Q_002_F_000_
  302. FROM dbo._InfoRg11710 T76
  303. WHERE ((T76._Fld595 = @P97)) AND ((T76._Fld12072RRef = T72._IDRRef) AND (T76._Fld12073_TYPE = CASE WHEN T70._Fld12836RRef IS NOT NULL THEN 0x08 END AND T76._Fld12073_RTRef = CASE WHEN T70._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T76._Fld12073_RRRef = T70._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  304. 0x01 AS Q_003_F_000_
  305. FROM dbo._InfoRg11715 T77
  306. WHERE ((T77._Fld595 = @P98)) AND ((T77._Fld12199RRef = T72._IDRRef) AND T77._Fld12200_TYPE = CASE WHEN T70._Fld12836RRef IS NOT NULL THEN 0x08 END AND T77._Fld12200_RTRef = CASE WHEN T70._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T77._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  307. T69._IDRRef AS IDRRef,
  308. T69._Fld4625RRef AS Fld4625RRef,
  309. T69._Fld595 AS Fld595_
  310. FROM dbo._Document233 T69
  311. WHERE (T69._Fld595 = @P99)) T68
  312. ON T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000E9 AND T66._Fld11251_RRRef = T68.IDRRef
  313. LEFT OUTER JOIN (SELECT
  314. CASE WHEN (EXISTS(SELECT
  315. 1
  316. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  317. LEFT OUTER JOIN dbo._Reference42 T80
  318. ON ((T79._Fld4774RRef = T80._IDRRef)) AND (T80._Fld595 = @P100)
  319. WHERE EXISTS(SELECT
  320. 0x01 AS Q_001_F_000_
  321. FROM dbo._Reference98 T81
  322. INNER JOIN dbo._Reference21 T82
  323. ON (((T81._Fld1685 = @P101) AND EXISTS(SELECT
  324. 0x01 AS Q_006_F_000_
  325. FROM dbo._InfoRg11709 T83
  326. WHERE ((T83._Fld595 = @P102)) AND ((T83._Fld12065RRef = T81._IDRRef) AND (T83._Fld12066RRef = T82._IDRRef)))) AND T82._IDRRef IN
  327. (SELECT
  328. T84._Reference21_IDRRef AS Q_007_F_000RRef
  329. FROM dbo._Reference21_VT782 T84
  330. INNER JOIN dbo._InfoRg9937 T85
  331. ON ((T85._Fld9939_TYPE = 0x08 AND T85._Fld9939_RTRef = 0x00000095 AND T85._Fld9939_RRRef = @P103) AND (T85._Fld9938_TYPE = T84._Fld784_TYPE AND T85._Fld9938_RTRef = T84._Fld784_RTRef AND T85._Fld9938_RRRef = T84._Fld784_RRRef))
  332. WHERE ((T84._Fld595 = @P104)) AND (T85._Fld595 = @P105)))
  333. WHERE ((T82._Fld595 = @P106)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  334. 0x01 AS Q_002_F_000_
  335. FROM dbo._InfoRg11710 T86
  336. WHERE ((T86._Fld595 = @P107)) AND ((T86._Fld12072RRef = T82._IDRRef) AND (T86._Fld12073_TYPE = 0x08 AND T86._Fld12073_RTRef = 0x0000001C AND T86._Fld12073_RRRef = T79._Fld4779RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  337. 0x01 AS Q_003_F_000_
  338. FROM dbo._InfoRg11715 T87
  339. WHERE ((T87._Fld595 = @P108)) AND ((T87._Fld12199RRef = T82._IDRRef) AND T87._Fld12200_TYPE = 0x08 AND T87._Fld12200_RTRef = 0x0000001C AND (T87._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) 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
  340. 0x01 AS Q_004_F_000_
  341. FROM dbo._InfoRg11710 T88
  342. WHERE ((T88._Fld595 = @P109)) AND ((T88._Fld12072RRef = T82._IDRRef) AND (T88._Fld12073_TYPE = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x08 END AND T88._Fld12073_RTRef = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T88._Fld12073_RRRef = T80._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  343. 0x01 AS Q_005_F_000_
  344. FROM dbo._InfoRg11715 T89
  345. WHERE ((T89._Fld595 = @P110)) AND ((T89._Fld12199RRef = T82._IDRRef) AND T89._Fld12200_TYPE = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x08 END AND T89._Fld12200_RTRef = CASE WHEN T80._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T89._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  346. T79._IDRRef AS IDRRef,
  347. T79._Fld595 AS Fld595_,
  348. T79._Fld4774RRef AS Fld4774RRef,
  349. T79._Fld4779RRef AS Fld4779RRef
  350. FROM dbo._Document234 T79
  351. WHERE (T79._Fld595 = @P111)) T78
  352. ON T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000EA AND T66._Fld11251_RRRef = T78.IDRRef
  353. LEFT OUTER JOIN dbo._Document286 T90
  354. ON (T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x0000011E AND T66._Fld11251_RRRef = T90._IDRRef) AND (T90._Fld595 = @P112)
  355. LEFT OUTER JOIN dbo._Document199 T91
  356. ON (T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000C7 AND T66._Fld11251_RRRef = T91._IDRRef) AND (T91._Fld595 = @P113)
  357. WHERE ((T66._Fld595 = @P114)) AND (T66._Period >= @P115 AND T66._Period <= @P116 AND T66._Active = 0x01 AND (((T66._Fld11246RRef = @P117) AND (CASE WHEN T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000DA THEN T67._Fld4083RRef WHEN T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000E9 THEN T68.Fld4625RRef WHEN T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000EA THEN T78.Fld4774RRef WHEN T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x0000011E THEN T90._Fld7289RRef WHEN T66._Fld11251_TYPE = 0x08 AND T66._Fld11251_RTRef = 0x000000C7 THEN T91._Fld2840RRef ELSE CAST(NULL AS BINARY(16)) END = @P118))))
  358. GROUP BY T66._Fld11251_TYPE,
  359. T66._Fld11251_RTRef,
  360. T66._Fld11251_RRRef
  361. HAVING (CAST(CAST(SUM(T66._Fld11255) AS NUMERIC(27, 8)) AS NUMERIC(27, 2))) <> 0.0) T39
  362. GROUP BY T39.Fld11251_TYPE,
  363. T39.Fld11251_RTRef,
  364. T39.Fld11251_RRRef
  365. HAVING (CAST(SUM(T39.Fld11255Turnover_) AS NUMERIC(38, 8))) <> 0.0) T38
  366. LEFT OUTER JOIN #tt44 T92 WITH(NOLOCK)
  367. ON (T92._Q_000_F_000RRef = @P119)
  368. LEFT OUTER JOIN dbo._Document218 T93
  369. ON (T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000DA AND T38.Fld11251_RRRef = T93._IDRRef) AND (T93._Fld595 = @P120)
  370. LEFT OUTER JOIN (SELECT
  371. CASE WHEN (EXISTS(SELECT
  372. 1
  373. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  374. LEFT OUTER JOIN dbo._Reference42 T96
  375. ON ((T95._Fld4625RRef = T96._IDRRef)) AND (T96._Fld595 = @P121)
  376. WHERE EXISTS(SELECT
  377. 0x01 AS Q_001_F_000_
  378. FROM dbo._Reference98 T97
  379. INNER JOIN dbo._Reference21 T98
  380. ON (((T97._Fld1685 = @P122) AND EXISTS(SELECT
  381. 0x01 AS Q_004_F_000_
  382. FROM dbo._InfoRg11709 T99
  383. WHERE ((T99._Fld595 = @P123)) AND ((T99._Fld12065RRef = T97._IDRRef) AND (T99._Fld12066RRef = T98._IDRRef)))) AND T98._IDRRef IN
  384. (SELECT
  385. T100._Reference21_IDRRef AS Q_005_F_000RRef
  386. FROM dbo._Reference21_VT782 T100
  387. INNER JOIN dbo._InfoRg9937 T101
  388. ON ((T101._Fld9939_TYPE = 0x08 AND T101._Fld9939_RTRef = 0x00000095 AND T101._Fld9939_RRRef = @P124) AND (T101._Fld9938_TYPE = T100._Fld784_TYPE AND T101._Fld9938_RTRef = T100._Fld784_RTRef AND T101._Fld9938_RRRef = T100._Fld784_RRRef))
  389. WHERE ((T100._Fld595 = @P125)) AND (T101._Fld595 = @P126)))
  390. WHERE ((T98._Fld595 = @P127)) AND ((CASE WHEN T96._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T96._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  391. 0x01 AS Q_002_F_000_
  392. FROM dbo._InfoRg11710 T102
  393. WHERE ((T102._Fld595 = @P128)) AND ((T102._Fld12072RRef = T98._IDRRef) AND (T102._Fld12073_TYPE = CASE WHEN T96._Fld12836RRef IS NOT NULL THEN 0x08 END AND T102._Fld12073_RTRef = CASE WHEN T96._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T102._Fld12073_RRRef = T96._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  394. 0x01 AS Q_003_F_000_
  395. FROM dbo._InfoRg11715 T103
  396. WHERE ((T103._Fld595 = @P129)) AND ((T103._Fld12199RRef = T98._IDRRef) AND T103._Fld12200_TYPE = CASE WHEN T96._Fld12836RRef IS NOT NULL THEN 0x08 END AND T103._Fld12200_RTRef = CASE WHEN T96._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T103._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  397. T95._IDRRef AS IDRRef,
  398. T95._Fld4625RRef AS Fld4625RRef,
  399. T95._Fld4627RRef AS Fld4627RRef,
  400. T95._Fld595 AS Fld595_
  401. FROM dbo._Document233 T95
  402. WHERE (T95._Fld595 = @P130)) T94
  403. ON T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000E9 AND T38.Fld11251_RRRef = T94.IDRRef
  404. LEFT OUTER JOIN (SELECT
  405. CASE WHEN (EXISTS(SELECT
  406. 1
  407. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  408. LEFT OUTER JOIN dbo._Reference42 T106
  409. ON ((T105._Fld4774RRef = T106._IDRRef)) AND (T106._Fld595 = @P131)
  410. WHERE EXISTS(SELECT
  411. 0x01 AS Q_001_F_000_
  412. FROM dbo._Reference98 T107
  413. INNER JOIN dbo._Reference21 T108
  414. ON (((T107._Fld1685 = @P132) AND EXISTS(SELECT
  415. 0x01 AS Q_006_F_000_
  416. FROM dbo._InfoRg11709 T109
  417. WHERE ((T109._Fld595 = @P133)) AND ((T109._Fld12065RRef = T107._IDRRef) AND (T109._Fld12066RRef = T108._IDRRef)))) AND T108._IDRRef IN
  418. (SELECT
  419. T110._Reference21_IDRRef AS Q_007_F_000RRef
  420. FROM dbo._Reference21_VT782 T110
  421. INNER JOIN dbo._InfoRg9937 T111
  422. ON ((T111._Fld9939_TYPE = 0x08 AND T111._Fld9939_RTRef = 0x00000095 AND T111._Fld9939_RRRef = @P134) AND (T111._Fld9938_TYPE = T110._Fld784_TYPE AND T111._Fld9938_RTRef = T110._Fld784_RTRef AND T111._Fld9938_RRRef = T110._Fld784_RRRef))
  423. WHERE ((T110._Fld595 = @P135)) AND (T111._Fld595 = @P136)))
  424. WHERE ((T108._Fld595 = @P137)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  425. 0x01 AS Q_002_F_000_
  426. FROM dbo._InfoRg11710 T112
  427. WHERE ((T112._Fld595 = @P138)) AND ((T112._Fld12072RRef = T108._IDRRef) AND (T112._Fld12073_TYPE = 0x08 AND T112._Fld12073_RTRef = 0x0000001C AND T112._Fld12073_RRRef = T105._Fld4779RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  428. 0x01 AS Q_003_F_000_
  429. FROM dbo._InfoRg11715 T113
  430. WHERE ((T113._Fld595 = @P139)) AND ((T113._Fld12199RRef = T108._IDRRef) AND T113._Fld12200_TYPE = 0x08 AND T113._Fld12200_RTRef = 0x0000001C AND (T113._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) AND (CASE WHEN T106._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T106._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  431. 0x01 AS Q_004_F_000_
  432. FROM dbo._InfoRg11710 T114
  433. WHERE ((T114._Fld595 = @P140)) AND ((T114._Fld12072RRef = T108._IDRRef) AND (T114._Fld12073_TYPE = CASE WHEN T106._Fld12836RRef IS NOT NULL THEN 0x08 END AND T114._Fld12073_RTRef = CASE WHEN T106._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T114._Fld12073_RRRef = T106._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  434. 0x01 AS Q_005_F_000_
  435. FROM dbo._InfoRg11715 T115
  436. WHERE ((T115._Fld595 = @P141)) AND ((T115._Fld12199RRef = T108._IDRRef) AND T115._Fld12200_TYPE = CASE WHEN T106._Fld12836RRef IS NOT NULL THEN 0x08 END AND T115._Fld12200_RTRef = CASE WHEN T106._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T115._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) THEN 0x01 ELSE 0x00 END AS SDBL_RLS_SIGNAL_,
  437. T105._IDRRef AS IDRRef,
  438. T105._Fld595 AS Fld595_,
  439. T105._Fld4774RRef AS Fld4774RRef,
  440. T105._Fld4776RRef AS Fld4776RRef,
  441. T105._Fld4779RRef AS Fld4779RRef
  442. FROM dbo._Document234 T105
  443. WHERE (T105._Fld595 = @P142)) T104
  444. ON T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000EA AND T38.Fld11251_RRRef = T104.IDRRef
  445. LEFT OUTER JOIN dbo._Document286 T116
  446. ON (T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x0000011E AND T38.Fld11251_RRRef = T116._IDRRef) AND (T116._Fld595 = @P143)
  447. LEFT OUTER JOIN dbo._Document199 T117
  448. ON (T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000C7 AND T38.Fld11251_RRRef = T117._IDRRef) AND (T117._Fld595 = @P144)
  449. ON CASE WHEN (T37._Q_001_F_000RRef = @P145) THEN 0x01 ELSE CASE WHEN (T37._Q_001_F_000RRef = CASE WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000DA THEN T93._Fld4084RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000E9 THEN T94.Fld4627RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000EA THEN T104.Fld4776RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x0000011E THEN T116._Fld7290RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000C7 THEN T117._Fld2841RRef ELSE CAST(NULL AS BINARY(16)) END) THEN 0x01 WHEN NOT (T37._Q_001_F_000RRef = CASE WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000DA THEN T93._Fld4084RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000E9 THEN T94.Fld4627RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000EA THEN T104.Fld4776RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x0000011E THEN T116._Fld7290RRef WHEN T38.Fld11251_TYPE = 0x08 AND T38.Fld11251_RTRef = 0x000000C7 THEN T117._Fld2841RRef ELSE CAST(NULL AS BINARY(16)) END) THEN 0x00 END END = 0x01
  450. WHERE ((T37._Q_001_F_001RRef = @P146)) AND CASE WHEN (T116._IDRRef = T116._IDRRef OR T116._IDRRef IS NULL) AND (T117._IDRRef = T117._IDRRef OR T117._IDRRef IS NULL) AND (T92._Q_000_F_000RRef = T92._Q_000_F_000RRef OR T92._Q_000_F_000RRef IS NULL) AND (T93._IDRRef = T93._IDRRef OR T93._IDRRef IS NULL) AND (T37._Q_001_F_001RRef = @P147) THEN CASE WHEN ISNULL(T38.SDBL_RLS_SIGNAL_,0x01) = 0x01 AND ISNULL(T94.SDBL_RLS_SIGNAL_,0x01) = 0x01 AND ISNULL(T104.SDBL_RLS_SIGNAL_,0x01) = 0x01 THEN 0 ELSE 2000000000 END + 2000000000 ELSE 0 END = 2000000000
  451. GROUP BY T37._Q_001_F_001RRef,
  452. T37._Q_001_F_002,
  453. T37._Q_001_F_000RRef,
  454. T37._Q_001_F_003RRef
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement