bytecoded

Top Query #5

Mar 12th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 117.22 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. 2.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 = ?)) 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 = ?)
  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 = ?)
  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 = ?)
  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 = ?)
  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 = ?)
  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 = ?)
  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 = ?)
  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 = ?)
  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 = ?)
  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 = ?) AND EXISTS(SELECT
  48. 0x01 AS Q_004_F_000_
  49. FROM dbo._InfoRg11709 T14
  50. WHERE ((T14._Fld595 = ?)) 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 = ?) 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 = ?)) AND (T16._Fld595 = ?)))
  57. WHERE ((T13._Fld595 = ?)) 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 = ?)) 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._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T17._Fld12073_RRRef = T11._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  61. 0x01 AS Q_003_F_000_
  62. FROM dbo._InfoRg11715 T18
  63. WHERE ((T18._Fld595 = ?)) AND ((T18._Fld12199RRef = T13._IDRRef) AND T18._Fld12200_TYPE = CASE WHEN T11._Fld12836RRef IS NOT NULL THEN 0x08 END AND T18._Fld12200_RTRef = CASE WHEN T11._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T18._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T2._Period >= ? AND T2._Period < ? AND ((T2._Fld11295RRef = ?)) AND (T2._Fld11302 <> ?))
  64. GROUP BY 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'}))),
  65. T2._Fld11293_TYPE,
  66. T2._Fld11293_RTRef,
  67. T2._Fld11293_RRRef
  68. HAVING (CAST(SUM(T2._Fld11302) AS NUMERIC(33, 8))) <> 0.0) T1
  69. LEFT OUTER JOIN (SELECT
  70. T20._IDRRef AS IDRRef,
  71. T20._Fld4625RRef AS Fld4625RRef,
  72. T20._Fld595 AS Fld595_
  73. FROM dbo._Document233 T20
  74. WHERE ((EXISTS(SELECT
  75. 1
  76. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  77. LEFT OUTER JOIN dbo._Reference42 T21
  78. ON ((T20._Fld4625RRef = T21._IDRRef)) AND (T21._Fld595 = ?)
  79. WHERE EXISTS(SELECT
  80. 0x01 AS Q_001_F_000_
  81. FROM dbo._Reference98 T22
  82. INNER JOIN dbo._Reference21 T23
  83. ON (((T22._Fld1685 = ?) AND EXISTS(SELECT
  84. 0x01 AS Q_004_F_000_
  85. FROM dbo._InfoRg11709 T24
  86. WHERE ((T24._Fld595 = ?)) AND ((T24._Fld12065RRef = T22._IDRRef) AND (T24._Fld12066RRef = T23._IDRRef)))) AND T23._IDRRef IN
  87. (SELECT
  88. T25._Reference21_IDRRef AS Q_005_F_000RRef
  89. FROM dbo._Reference21_VT782 T25
  90. INNER JOIN dbo._InfoRg9937 T26
  91. ON ((T26._Fld9939_TYPE = 0x08 AND T26._Fld9939_RTRef = 0x00000095 AND T26._Fld9939_RRRef = ?) AND (T26._Fld9938_TYPE = T25._Fld784_TYPE AND T26._Fld9938_RTRef = T25._Fld784_RTRef AND T26._Fld9938_RRRef = T25._Fld784_RRRef))
  92. WHERE ((T25._Fld595 = ?)) AND (T26._Fld595 = ?)))
  93. WHERE ((T23._Fld595 = ?)) AND ((CASE WHEN T21._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  94. 0x01 AS Q_002_F_000_
  95. FROM dbo._InfoRg11710 T27
  96. WHERE ((T27._Fld595 = ?)) AND ((T27._Fld12072RRef = T23._IDRRef) AND (T27._Fld12073_TYPE = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x08 END AND T27._Fld12073_RTRef = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T27._Fld12073_RRRef = T21._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  97. 0x01 AS Q_003_F_000_
  98. FROM dbo._InfoRg11715 T28
  99. WHERE ((T28._Fld595 = ?)) AND ((T28._Fld12199RRef = T23._IDRRef) AND T28._Fld12200_TYPE = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x08 END AND T28._Fld12200_RTRef = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T28._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T20._Fld595 = ?)) T19
  100. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000E9 AND T1.Fld11293_RRRef = T19.IDRRef
  101. LEFT OUTER JOIN dbo._Document212 T29
  102. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D4 AND T1.Fld11293_RRRef = T29._IDRRef) AND (T29._Fld595 = ?)
  103. LEFT OUTER JOIN (SELECT
  104. T31._IDRRef AS IDRRef,
  105. T31._Fld4779RRef AS Fld4779RRef,
  106. T31._Fld595 AS Fld595_,
  107. T31._Fld4774RRef AS Fld4774RRef
  108. FROM dbo._Document234 T31
  109. WHERE ((EXISTS(SELECT
  110. 1
  111. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  112. LEFT OUTER JOIN dbo._Reference42 T32
  113. ON ((T31._Fld4774RRef = T32._IDRRef)) AND (T32._Fld595 = ?)
  114. WHERE EXISTS(SELECT
  115. 0x01 AS Q_001_F_000_
  116. FROM dbo._Reference98 T33
  117. INNER JOIN dbo._Reference21 T34
  118. ON (((T33._Fld1685 = ?) AND EXISTS(SELECT
  119. 0x01 AS Q_006_F_000_
  120. FROM dbo._InfoRg11709 T35
  121. WHERE ((T35._Fld595 = ?)) AND ((T35._Fld12065RRef = T33._IDRRef) AND (T35._Fld12066RRef = T34._IDRRef)))) AND T34._IDRRef IN
  122. (SELECT
  123. T36._Reference21_IDRRef AS Q_007_F_000RRef
  124. FROM dbo._Reference21_VT782 T36
  125. INNER JOIN dbo._InfoRg9937 T37
  126. ON ((T37._Fld9939_TYPE = 0x08 AND T37._Fld9939_RTRef = 0x00000095 AND T37._Fld9939_RRRef = ?) AND (T37._Fld9938_TYPE = T36._Fld784_TYPE AND T37._Fld9938_RTRef = T36._Fld784_RTRef AND T37._Fld9938_RRRef = T36._Fld784_RRRef))
  127. WHERE ((T36._Fld595 = ?)) AND (T37._Fld595 = ?)))
  128. WHERE ((T34._Fld595 = ?)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  129. 0x01 AS Q_002_F_000_
  130. FROM dbo._InfoRg11710 T38
  131. WHERE ((T38._Fld595 = ?)) AND ((T38._Fld12072RRef = T34._IDRRef) AND (T38._Fld12073_TYPE = 0x08 AND T38._Fld12073_RTRef = 0x0000001C AND T38._Fld12073_RRRef = T31._Fld4779RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  132. 0x01 AS Q_003_F_000_
  133. FROM dbo._InfoRg11715 T39
  134. WHERE ((T39._Fld595 = ?)) AND ((T39._Fld12199RRef = T34._IDRRef) AND T39._Fld12200_TYPE = 0x08 AND T39._Fld12200_RTRef = 0x0000001C AND (T39._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) AND (CASE WHEN T32._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  135. 0x01 AS Q_004_F_000_
  136. FROM dbo._InfoRg11710 T40
  137. WHERE ((T40._Fld595 = ?)) AND ((T40._Fld12072RRef = T34._IDRRef) AND (T40._Fld12073_TYPE = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x08 END AND T40._Fld12073_RTRef = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T40._Fld12073_RRRef = T32._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  138. 0x01 AS Q_005_F_000_
  139. FROM dbo._InfoRg11715 T41
  140. WHERE ((T41._Fld595 = ?)) AND ((T41._Fld12199RRef = T34._IDRRef) AND T41._Fld12200_TYPE = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x08 END AND T41._Fld12200_RTRef = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T41._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T31._Fld595 = ?)) T30
  141. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000EA AND T1.Fld11293_RRRef = T30.IDRRef
  142. LEFT OUTER JOIN dbo._Document263 T42
  143. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x00000107 AND T1.Fld11293_RRRef = T42._IDRRef) AND (T42._Fld595 = ?)
  144. LEFT OUTER JOIN (SELECT
  145. T44._IDRRef AS IDRRef,
  146. T44._Fld3845RRef AS Fld3845RRef,
  147. T44._Fld595 AS Fld595_
  148. FROM dbo._Document216 T44
  149. WHERE ((EXISTS(SELECT
  150. 1
  151. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  152. LEFT OUTER JOIN dbo._Reference42 T45
  153. ON ((T44._Fld3845RRef = T45._IDRRef)) AND (T45._Fld595 = ?)
  154. WHERE EXISTS(SELECT
  155. 0x01 AS Q_001_F_000_
  156. FROM dbo._Reference98 T46
  157. INNER JOIN dbo._Reference21 T47
  158. ON (((T46._Fld1685 = ?) AND EXISTS(SELECT
  159. 0x01 AS Q_004_F_000_
  160. FROM dbo._InfoRg11709 T48
  161. WHERE ((T48._Fld595 = ?)) AND ((T48._Fld12065RRef = T46._IDRRef) AND (T48._Fld12066RRef = T47._IDRRef)))) AND T47._IDRRef IN
  162. (SELECT
  163. T49._Reference21_IDRRef AS Q_005_F_000RRef
  164. FROM dbo._Reference21_VT782 T49
  165. INNER JOIN dbo._InfoRg9937 T50
  166. ON ((T50._Fld9939_TYPE = 0x08 AND T50._Fld9939_RTRef = 0x00000095 AND T50._Fld9939_RRRef = ?) AND (T50._Fld9938_TYPE = T49._Fld784_TYPE AND T50._Fld9938_RTRef = T49._Fld784_RTRef AND T50._Fld9938_RRRef = T49._Fld784_RRRef))
  167. WHERE ((T49._Fld595 = ?)) AND (T50._Fld595 = ?)))
  168. WHERE ((T47._Fld595 = ?)) AND ((CASE WHEN T45._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  169. 0x01 AS Q_002_F_000_
  170. FROM dbo._InfoRg11710 T51
  171. WHERE ((T51._Fld595 = ?)) AND ((T51._Fld12072RRef = T47._IDRRef) AND (T51._Fld12073_TYPE = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x08 END AND T51._Fld12073_RTRef = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T51._Fld12073_RRRef = T45._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  172. 0x01 AS Q_003_F_000_
  173. FROM dbo._InfoRg11715 T52
  174. WHERE ((T52._Fld595 = ?)) AND ((T52._Fld12199RRef = T47._IDRRef) AND T52._Fld12200_TYPE = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x08 END AND T52._Fld12200_RTRef = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T52._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T44._Fld595 = ?)) T43
  175. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D8 AND T1.Fld11293_RRRef = T43.IDRRef
  176. LEFT OUTER JOIN (SELECT
  177. T54._Fld595 AS Fld595_,
  178. T54._IDRRef AS IDRRef,
  179. T54._Fld3734RRef AS Fld3734RRef
  180. FROM dbo._Document215 T54
  181. WHERE ((EXISTS(SELECT
  182. 1
  183. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  184. LEFT OUTER JOIN dbo._Reference42 T55
  185. ON ((T54._Fld3734RRef = T55._IDRRef)) AND (T55._Fld595 = ?)
  186. WHERE EXISTS(SELECT
  187. 0x01 AS Q_001_F_000_
  188. FROM dbo._Reference98 T56
  189. INNER JOIN dbo._Reference21 T57
  190. ON (((T56._Fld1685 = ?) AND EXISTS(SELECT
  191. 0x01 AS Q_004_F_000_
  192. FROM dbo._InfoRg11709 T58
  193. WHERE ((T58._Fld595 = ?)) AND ((T58._Fld12065RRef = T56._IDRRef) AND (T58._Fld12066RRef = T57._IDRRef)))) AND T57._IDRRef IN
  194. (SELECT
  195. T59._Reference21_IDRRef AS Q_005_F_000RRef
  196. FROM dbo._Reference21_VT782 T59
  197. INNER JOIN dbo._InfoRg9937 T60
  198. ON ((T60._Fld9939_TYPE = 0x08 AND T60._Fld9939_RTRef = 0x00000095 AND T60._Fld9939_RRRef = ?) AND (T60._Fld9938_TYPE = T59._Fld784_TYPE AND T60._Fld9938_RTRef = T59._Fld784_RTRef AND T60._Fld9938_RRRef = T59._Fld784_RRRef))
  199. WHERE ((T59._Fld595 = ?)) AND (T60._Fld595 = ?)))
  200. WHERE ((T57._Fld595 = ?)) 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
  201. 0x01 AS Q_002_F_000_
  202. FROM dbo._InfoRg11710 T61
  203. WHERE ((T61._Fld595 = ?)) 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
  204. 0x01 AS Q_003_F_000_
  205. FROM dbo._InfoRg11715 T62
  206. WHERE ((T62._Fld595 = ?)) 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 = ?)) T53
  207. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D7 AND T1.Fld11293_RRRef = T53.IDRRef
  208. LEFT OUTER JOIN dbo._Document213 T63
  209. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D5 AND T1.Fld11293_RRRef = T63._IDRRef) AND (T63._Fld595 = ?)
  210. LEFT OUTER JOIN dbo._Document199 T64
  211. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000C7 AND T1.Fld11293_RRRef = T64._IDRRef) AND (T64._Fld595 = ?)
  212. LEFT OUTER JOIN (SELECT
  213. T66._IDRRef AS IDRRef,
  214. T66._Fld12836RRef AS Fld12836RRef,
  215. T66._Fld595 AS Fld595_,
  216. T66._Folder AS Folder_,
  217. T66._Description COLLATE Latin1_General_CI_AS AS Description_
  218. FROM dbo._Reference42 T66
  219. WHERE ((T66._IDRRef = ?) AND (((T66._Folder = 0x00) OR EXISTS(SELECT
  220. 0x01 AS Q_001_F_000_
  221. FROM dbo._Reference98 T67
  222. INNER JOIN dbo._Reference21 T68
  223. ON (((T67._Fld1685 = ?) AND EXISTS(SELECT
  224. 0x01 AS Q_004_F_000_
  225. FROM dbo._InfoRg11709 T69
  226. WHERE ((T69._Fld595 = ?)) AND ((T69._Fld12065RRef = T67._IDRRef) AND (T69._Fld12066RRef = T68._IDRRef)))) AND T68._IDRRef IN
  227. (SELECT
  228. T70._Reference21_IDRRef AS Q_005_F_000RRef
  229. FROM dbo._Reference21_VT782 T70
  230. INNER JOIN dbo._InfoRg9937 T71
  231. ON ((T71._Fld9939_TYPE = 0x08 AND T71._Fld9939_RTRef = 0x00000095 AND T71._Fld9939_RRRef = ?) AND (T71._Fld9938_TYPE = T70._Fld784_TYPE AND T71._Fld9938_RTRef = T70._Fld784_RTRef AND T71._Fld9938_RRRef = T70._Fld784_RRRef))
  232. WHERE ((T70._Fld595 = ?)) AND (T71._Fld595 = ?)))
  233. WHERE ((T68._Fld595 = ?)) 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
  234. 0x01 AS Q_002_F_000_
  235. FROM dbo._InfoRg11710 T72
  236. WHERE ((T72._Fld595 = ?)) AND ((T72._Fld12072RRef = T68._IDRRef) AND (T72._Fld12073_TYPE = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x08 END AND T72._Fld12073_RTRef = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T72._Fld12073_RRRef = T66._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  237. 0x01 AS Q_003_F_000_
  238. FROM dbo._InfoRg11715 T73
  239. WHERE ((T73._Fld595 = ?)) AND ((T73._Fld12199RRef = T68._IDRRef) AND T73._Fld12200_TYPE = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x08 END AND T73._Fld12200_RTRef = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T73._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T66._Fld595 = ?)) T65
  240. ON (CASE WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000E9 THEN T19.Fld4625RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D4 THEN T29._Fld3516RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000EA THEN T30.Fld4774RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x00000107 THEN T42._Fld6287RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D8 THEN T43.Fld3845RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D7 THEN T53.Fld3734RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D5 THEN T63._Fld3600RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000C7 THEN T64._Fld2840RRef ELSE CAST(NULL AS BINARY(16)) END = T65.IDRRef)
  241. LEFT OUTER JOIN dbo._Reference28 T74
  242. ON (T65.Fld12836RRef = T74._IDRRef) AND (T74._Fld595 = ?)
  243. WHERE (T65.IDRRef = ?)
  244. UNION ALL SELECT
  245. DATEADD(DAY,1.0 - 1,DATEADD(MONTH,CAST(DATEPART(MONTH,T97.Date_Time_) AS NUMERIC(4)) - 1,DATEADD(YEAR,(CAST(DATEPART(YEAR,T97.Date_Time_) AS NUMERIC(4)) - 2000) - 2000,?))),
  246. CAST(0.0 AS NUMERIC(27, 2)),
  247. T88.Fld12836RRef,
  248. T88.IDRRef,
  249. T75.Fld10532Receipt_,
  250. CAST(0.0 AS NUMERIC(21, 2)),
  251. T88.IDRRef,
  252. T88.Description_,
  253. T88.Description_,
  254. T88.Fld12836RRef,
  255. T107._Description,
  256. 3.0,
  257. T107._Description
  258. FROM (SELECT
  259. T76._RecorderTRef AS RecorderTRef,
  260. T76._RecorderRRef AS RecorderRRef,
  261. T76._Fld10530_TYPE AS Fld10530_TYPE,
  262. T76._Fld10530_RTRef AS Fld10530_RTRef,
  263. T76._Fld10530_RRRef AS Fld10530_RRRef,
  264. CAST(SUM(CASE WHEN T76._RecordKind = 0.0 THEN T76._Fld10532 ELSE 0.0 END) AS NUMERIC(27, 8)) AS Fld10532Receipt_
  265. FROM dbo._AccumRg10527 T76
  266. WHERE ((T76._Fld595 = ?)) AND (T76._Period <= ? AND T76._Active = 0x01 AND (((T76._Fld10528RRef = ?))) AND T76._RecordKind = ?)
  267. GROUP BY T76._RecorderTRef,
  268. T76._RecorderRRef,
  269. T76._Fld10530_TYPE,
  270. T76._Fld10530_RTRef,
  271. T76._Fld10530_RRRef
  272. HAVING (CAST(SUM(CASE WHEN T76._RecordKind = 0.0 THEN T76._Fld10532 ELSE 0.0 END) AS NUMERIC(27, 8))) <> 0.0) T75
  273. LEFT OUTER JOIN (SELECT
  274. T78._IDRRef AS IDRRef,
  275. T78._Fld3438RRef AS Fld3438RRef,
  276. T78._Fld595 AS Fld595_
  277. FROM dbo._Document211 T78
  278. WHERE ((EXISTS(SELECT
  279. 1
  280. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  281. LEFT OUTER JOIN dbo._Reference42 T79
  282. ON ((T78._Fld3438RRef = T79._IDRRef)) AND (T79._Fld595 = ?)
  283. WHERE EXISTS(SELECT
  284. 0x01 AS Q_001_F_000_
  285. FROM dbo._Reference98 T80
  286. INNER JOIN dbo._Reference21 T81
  287. ON (((T80._Fld1685 = ?) AND EXISTS(SELECT
  288. 0x01 AS Q_004_F_000_
  289. FROM dbo._InfoRg11709 T82
  290. WHERE ((T82._Fld595 = ?)) AND ((T82._Fld12065RRef = T80._IDRRef) AND (T82._Fld12066RRef = T81._IDRRef)))) AND T81._IDRRef IN
  291. (SELECT
  292. T83._Reference21_IDRRef AS Q_005_F_000RRef
  293. FROM dbo._Reference21_VT782 T83
  294. INNER JOIN dbo._InfoRg9937 T84
  295. ON ((T84._Fld9939_TYPE = 0x08 AND T84._Fld9939_RTRef = 0x00000095 AND T84._Fld9939_RRRef = ?) AND (T84._Fld9938_TYPE = T83._Fld784_TYPE AND T84._Fld9938_RTRef = T83._Fld784_RTRef AND T84._Fld9938_RRRef = T83._Fld784_RRRef))
  296. WHERE ((T83._Fld595 = ?)) AND (T84._Fld595 = ?)))
  297. WHERE ((T81._Fld595 = ?)) AND ((CASE WHEN T79._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T79._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  298. 0x01 AS Q_002_F_000_
  299. FROM dbo._InfoRg11710 T85
  300. WHERE ((T85._Fld595 = ?)) AND ((T85._Fld12072RRef = T81._IDRRef) AND (T85._Fld12073_TYPE = CASE WHEN T79._Fld12836RRef IS NOT NULL THEN 0x08 END AND T85._Fld12073_RTRef = CASE WHEN T79._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T85._Fld12073_RRRef = T79._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  301. 0x01 AS Q_003_F_000_
  302. FROM dbo._InfoRg11715 T86
  303. WHERE ((T86._Fld595 = ?)) AND ((T86._Fld12199RRef = T81._IDRRef) AND T86._Fld12200_TYPE = CASE WHEN T79._Fld12836RRef IS NOT NULL THEN 0x08 END AND T86._Fld12200_RTRef = CASE WHEN T79._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T86._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T78._Fld595 = ?)) T77
  304. ON T75.Fld10530_TYPE = 0x08 AND T75.Fld10530_RTRef = 0x000000D3 AND T75.Fld10530_RRRef = T77.IDRRef
  305. LEFT OUTER JOIN dbo._Document210 T87
  306. ON (T75.Fld10530_TYPE = 0x08 AND T75.Fld10530_RTRef = 0x000000D2 AND T75.Fld10530_RRRef = T87._IDRRef) AND (T87._Fld595 = ?)
  307. LEFT OUTER JOIN (SELECT
  308. T89._IDRRef AS IDRRef,
  309. T89._Fld12836RRef AS Fld12836RRef,
  310. T89._Fld595 AS Fld595_,
  311. T89._Folder AS Folder_,
  312. T89._Description COLLATE Latin1_General_CI_AS AS Description_
  313. FROM dbo._Reference42 T89
  314. WHERE ((T89._IDRRef = ?) AND (((T89._Folder = 0x00) OR EXISTS(SELECT
  315. 0x01 AS Q_001_F_000_
  316. FROM dbo._Reference98 T90
  317. INNER JOIN dbo._Reference21 T91
  318. ON (((T90._Fld1685 = ?) AND EXISTS(SELECT
  319. 0x01 AS Q_004_F_000_
  320. FROM dbo._InfoRg11709 T92
  321. WHERE ((T92._Fld595 = ?)) AND ((T92._Fld12065RRef = T90._IDRRef) AND (T92._Fld12066RRef = T91._IDRRef)))) AND T91._IDRRef IN
  322. (SELECT
  323. T93._Reference21_IDRRef AS Q_005_F_000RRef
  324. FROM dbo._Reference21_VT782 T93
  325. INNER JOIN dbo._InfoRg9937 T94
  326. ON ((T94._Fld9939_TYPE = 0x08 AND T94._Fld9939_RTRef = 0x00000095 AND T94._Fld9939_RRRef = ?) AND (T94._Fld9938_TYPE = T93._Fld784_TYPE AND T94._Fld9938_RTRef = T93._Fld784_RTRef AND T94._Fld9938_RRRef = T93._Fld784_RRRef))
  327. WHERE ((T93._Fld595 = ?)) AND (T94._Fld595 = ?)))
  328. WHERE ((T91._Fld595 = ?)) AND ((CASE WHEN T89._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T89._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  329. 0x01 AS Q_002_F_000_
  330. FROM dbo._InfoRg11710 T95
  331. WHERE ((T95._Fld595 = ?)) AND ((T95._Fld12072RRef = T91._IDRRef) AND (T95._Fld12073_TYPE = CASE WHEN T89._Fld12836RRef IS NOT NULL THEN 0x08 END AND T95._Fld12073_RTRef = CASE WHEN T89._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T95._Fld12073_RRRef = T89._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  332. 0x01 AS Q_003_F_000_
  333. FROM dbo._InfoRg11715 T96
  334. WHERE ((T96._Fld595 = ?)) AND ((T96._Fld12199RRef = T91._IDRRef) AND T96._Fld12200_TYPE = CASE WHEN T89._Fld12836RRef IS NOT NULL THEN 0x08 END AND T96._Fld12200_RTRef = CASE WHEN T89._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T96._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T89._Fld595 = ?)) T88
  335. ON (CASE WHEN T75.Fld10530_TYPE = 0x08 AND T75.Fld10530_RTRef = 0x000000D3 THEN T77.Fld3438RRef WHEN T75.Fld10530_TYPE = 0x08 AND T75.Fld10530_RTRef = 0x000000D2 THEN T87._Fld3343RRef ELSE CAST(NULL AS BINARY(16)) END = T88.IDRRef)
  336. LEFT OUTER JOIN (SELECT
  337. T98._Date_Time AS Date_Time_,
  338. T98._IDRRef AS IDRRef,
  339. T98._Fld3438RRef AS Fld3438RRef,
  340. T98._Fld595 AS Fld595_,
  341. T98._Fld3452RRef AS Fld3452RRef
  342. FROM dbo._Document211 T98
  343. WHERE ((EXISTS(SELECT
  344. 1
  345. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  346. LEFT OUTER JOIN dbo._Reference42 T99
  347. ON ((T98._Fld3438RRef = T99._IDRRef)) AND (T99._Fld595 = ?)
  348. WHERE EXISTS(SELECT
  349. 0x01 AS Q_001_F_000_
  350. FROM dbo._Reference98 T100
  351. INNER JOIN dbo._Reference21 T101
  352. ON (((T100._Fld1685 = ?) AND EXISTS(SELECT
  353. 0x01 AS Q_004_F_000_
  354. FROM dbo._InfoRg11709 T102
  355. WHERE ((T102._Fld595 = ?)) AND ((T102._Fld12065RRef = T100._IDRRef) AND (T102._Fld12066RRef = T101._IDRRef)))) AND T101._IDRRef IN
  356. (SELECT
  357. T103._Reference21_IDRRef AS Q_005_F_000RRef
  358. FROM dbo._Reference21_VT782 T103
  359. INNER JOIN dbo._InfoRg9937 T104
  360. ON ((T104._Fld9939_TYPE = 0x08 AND T104._Fld9939_RTRef = 0x00000095 AND T104._Fld9939_RRRef = ?) AND (T104._Fld9938_TYPE = T103._Fld784_TYPE AND T104._Fld9938_RTRef = T103._Fld784_RTRef AND T104._Fld9938_RRRef = T103._Fld784_RRRef))
  361. WHERE ((T103._Fld595 = ?)) AND (T104._Fld595 = ?)))
  362. WHERE ((T101._Fld595 = ?)) AND ((CASE WHEN T99._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T99._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  363. 0x01 AS Q_002_F_000_
  364. FROM dbo._InfoRg11710 T105
  365. WHERE ((T105._Fld595 = ?)) AND ((T105._Fld12072RRef = T101._IDRRef) AND (T105._Fld12073_TYPE = CASE WHEN T99._Fld12836RRef IS NOT NULL THEN 0x08 END AND T105._Fld12073_RTRef = CASE WHEN T99._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T105._Fld12073_RRRef = T99._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  366. 0x01 AS Q_003_F_000_
  367. FROM dbo._InfoRg11715 T106
  368. WHERE ((T106._Fld595 = ?)) AND ((T106._Fld12199RRef = T101._IDRRef) AND T106._Fld12200_TYPE = CASE WHEN T99._Fld12836RRef IS NOT NULL THEN 0x08 END AND T106._Fld12200_RTRef = CASE WHEN T99._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T106._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T98._Fld595 = ?)) T97
  369. ON T75.RecorderTRef = 0x000000D3 AND T75.RecorderRRef = T97.IDRRef
  370. LEFT OUTER JOIN dbo._Reference28 T107
  371. ON (T88.Fld12836RRef = T107._IDRRef) AND (T107._Fld595 = ?)
  372. LEFT OUTER JOIN dbo._Document253 T108
  373. ON (T75.RecorderTRef = 0x000000FD AND T75.RecorderRRef = T108._IDRRef) AND (T108._Fld595 = ?)
  374. LEFT OUTER JOIN (SELECT
  375. T110._IDRRef AS IDRRef,
  376. T110._Date_Time AS Date_Time_,
  377. T110._Fld595 AS Fld595_,
  378. T110._Fld6155RRef AS Fld6155RRef,
  379. T110._Fld6139RRef AS Fld6139RRef
  380. FROM dbo._Document259 T110
  381. WHERE ((EXISTS(SELECT
  382. 1
  383. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  384. LEFT OUTER JOIN dbo._Reference42 T111
  385. ON ((T110._Fld6139RRef = T111._IDRRef)) AND (T111._Fld595 = ?)
  386. WHERE EXISTS(SELECT
  387. 0x01 AS Q_001_F_000_
  388. FROM dbo._Reference98 T112
  389. INNER JOIN dbo._Reference21 T113
  390. ON (((T112._Fld1685 = ?) AND EXISTS(SELECT
  391. 0x01 AS Q_004_F_000_
  392. FROM dbo._InfoRg11709 T114
  393. WHERE ((T114._Fld595 = ?)) AND ((T114._Fld12065RRef = T112._IDRRef) AND (T114._Fld12066RRef = T113._IDRRef)))) AND T113._IDRRef IN
  394. (SELECT
  395. T115._Reference21_IDRRef AS Q_005_F_000RRef
  396. FROM dbo._Reference21_VT782 T115
  397. INNER JOIN dbo._InfoRg9937 T116
  398. ON ((T116._Fld9939_TYPE = 0x08 AND T116._Fld9939_RTRef = 0x00000095 AND T116._Fld9939_RRRef = ?) AND (T116._Fld9938_TYPE = T115._Fld784_TYPE AND T116._Fld9938_RTRef = T115._Fld784_RTRef AND T116._Fld9938_RRRef = T115._Fld784_RRRef))
  399. WHERE ((T115._Fld595 = ?)) AND (T116._Fld595 = ?)))
  400. WHERE ((T113._Fld595 = ?)) AND ((CASE WHEN T111._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T111._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  401. 0x01 AS Q_002_F_000_
  402. FROM dbo._InfoRg11710 T117
  403. WHERE ((T117._Fld595 = ?)) AND ((T117._Fld12072RRef = T113._IDRRef) AND (T117._Fld12073_TYPE = CASE WHEN T111._Fld12836RRef IS NOT NULL THEN 0x08 END AND T117._Fld12073_RTRef = CASE WHEN T111._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T117._Fld12073_RRRef = T111._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  404. 0x01 AS Q_003_F_000_
  405. FROM dbo._InfoRg11715 T118
  406. WHERE ((T118._Fld595 = ?)) AND ((T118._Fld12199RRef = T113._IDRRef) AND T118._Fld12200_TYPE = CASE WHEN T111._Fld12836RRef IS NOT NULL THEN 0x08 END AND T118._Fld12200_RTRef = CASE WHEN T111._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T118._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T110._Fld595 = ?)) T109
  407. ON T75.RecorderTRef = 0x00000103 AND T75.RecorderRRef = T109.IDRRef
  408. LEFT OUTER JOIN (SELECT
  409. T120._IDRRef AS IDRRef,
  410. T120._Fld3325_TYPE AS Fld3325_TYPE,
  411. T120._Fld3325_RTRef AS Fld3325_RTRef,
  412. T120._Fld3325_RRRef AS Fld3325_RRRef,
  413. T120._Fld595 AS Fld595_,
  414. T120._Date_Time AS Date_Time_
  415. FROM dbo._Document209 T120
  416. WHERE ((EXISTS(SELECT
  417. 1
  418. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  419. LEFT OUTER JOIN dbo._Document211 T121
  420. ON (T120._Fld3325_TYPE = 0x08 AND T120._Fld3325_RTRef = 0x000000D3 AND T120._Fld3325_RRRef = T121._IDRRef) AND (T121._Fld595 = ?)
  421. LEFT OUTER JOIN dbo._Document210 T122
  422. ON (T120._Fld3325_TYPE = 0x08 AND T120._Fld3325_RTRef = 0x000000D2 AND T120._Fld3325_RRRef = T122._IDRRef) AND (T122._Fld595 = ?)
  423. LEFT OUTER JOIN dbo._Reference42 T123
  424. ON ((CASE WHEN T120._Fld3325_TYPE = 0x08 AND T120._Fld3325_RTRef = 0x000000D3 THEN T121._Fld3438RRef WHEN T120._Fld3325_TYPE = 0x08 AND T120._Fld3325_RTRef = 0x000000D2 THEN T122._Fld3343RRef ELSE CAST(NULL AS BINARY(16)) END = T123._IDRRef)) AND (T123._Fld595 = ?)
  425. WHERE EXISTS(SELECT
  426. 0x01 AS Q_001_F_000_
  427. FROM dbo._Reference98 T124
  428. INNER JOIN dbo._Reference21 T125
  429. ON (((T124._Fld1685 = ?) AND EXISTS(SELECT
  430. 0x01 AS Q_004_F_000_
  431. FROM dbo._InfoRg11709 T126
  432. WHERE ((T126._Fld595 = ?)) AND ((T126._Fld12065RRef = T124._IDRRef) AND (T126._Fld12066RRef = T125._IDRRef)))) AND T125._IDRRef IN
  433. (SELECT
  434. T127._Reference21_IDRRef AS Q_005_F_000RRef
  435. FROM dbo._Reference21_VT782 T127
  436. INNER JOIN dbo._InfoRg9937 T128
  437. ON ((T128._Fld9939_TYPE = 0x08 AND T128._Fld9939_RTRef = 0x00000095 AND T128._Fld9939_RRRef = ?) AND (T128._Fld9938_TYPE = T127._Fld784_TYPE AND T128._Fld9938_RTRef = T127._Fld784_RTRef AND T128._Fld9938_RRRef = T127._Fld784_RRRef))
  438. WHERE ((T127._Fld595 = ?)) AND (T128._Fld595 = ?)))
  439. WHERE ((T125._Fld595 = ?)) AND ((CASE WHEN T123._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T123._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  440. 0x01 AS Q_002_F_000_
  441. FROM dbo._InfoRg11710 T129
  442. WHERE ((T129._Fld595 = ?)) AND ((T129._Fld12072RRef = T125._IDRRef) AND (T129._Fld12073_TYPE = CASE WHEN T123._Fld12836RRef IS NOT NULL THEN 0x08 END AND T129._Fld12073_RTRef = CASE WHEN T123._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T129._Fld12073_RRRef = T123._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  443. 0x01 AS Q_003_F_000_
  444. FROM dbo._InfoRg11715 T130
  445. WHERE ((T130._Fld595 = ?)) AND ((T130._Fld12199RRef = T125._IDRRef) AND T130._Fld12200_TYPE = CASE WHEN T123._Fld12836RRef IS NOT NULL THEN 0x08 END AND T130._Fld12200_RTRef = CASE WHEN T123._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T130._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T120._Fld595 = ?)) T119
  446. ON T75.RecorderTRef = 0x000000D1 AND T75.RecorderRRef = T119.IDRRef
  447. LEFT OUTER JOIN (SELECT
  448. T132._Fld5855RRef AS Fld5855RRef,
  449. T132._IDRRef AS IDRRef,
  450. T132._Date_Time AS Date_Time_,
  451. T132._Fld5875RRef AS Fld5875RRef,
  452. T132._Fld595 AS Fld595_
  453. FROM dbo._Document255 T132
  454. WHERE ((EXISTS(SELECT
  455. 1
  456. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  457. LEFT OUTER JOIN dbo._Reference42 T133
  458. ON ((T132._Fld5855RRef = T133._IDRRef)) AND (T133._Fld595 = ?)
  459. WHERE EXISTS(SELECT
  460. 0x01 AS Q_001_F_000_
  461. FROM dbo._Reference98 T134
  462. INNER JOIN dbo._Reference21 T135
  463. ON (((T134._Fld1685 = ?) AND EXISTS(SELECT
  464. 0x01 AS Q_004_F_000_
  465. FROM dbo._InfoRg11709 T136
  466. WHERE ((T136._Fld595 = ?)) AND ((T136._Fld12065RRef = T134._IDRRef) AND (T136._Fld12066RRef = T135._IDRRef)))) AND T135._IDRRef IN
  467. (SELECT
  468. T137._Reference21_IDRRef AS Q_005_F_000RRef
  469. FROM dbo._Reference21_VT782 T137
  470. INNER JOIN dbo._InfoRg9937 T138
  471. ON ((T138._Fld9939_TYPE = 0x08 AND T138._Fld9939_RTRef = 0x00000095 AND T138._Fld9939_RRRef = ?) AND (T138._Fld9938_TYPE = T137._Fld784_TYPE AND T138._Fld9938_RTRef = T137._Fld784_RTRef AND T138._Fld9938_RRRef = T137._Fld784_RRRef))
  472. WHERE ((T137._Fld595 = ?)) AND (T138._Fld595 = ?)))
  473. WHERE ((T135._Fld595 = ?)) 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
  474. 0x01 AS Q_002_F_000_
  475. FROM dbo._InfoRg11710 T139
  476. WHERE ((T139._Fld595 = ?)) 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
  477. 0x01 AS Q_003_F_000_
  478. FROM dbo._InfoRg11715 T140
  479. WHERE ((T140._Fld595 = ?)) 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._Fld595 = ?)) T131
  480. ON T75.RecorderTRef = 0x000000FF AND T75.RecorderRRef = T131.IDRRef
  481. LEFT OUTER JOIN dbo._Document210 T141
  482. ON (T75.RecorderTRef = 0x000000D2 AND T75.RecorderRRef = T141._IDRRef) AND (T141._Fld595 = ?)
  483. WHERE (CASE WHEN T75.RecorderTRef = 0x000000FD THEN T108._Date_Time WHEN T75.RecorderTRef = 0x00000103 THEN T109.Date_Time_ WHEN T75.RecorderTRef = 0x000000D1 THEN T119.Date_Time_ WHEN T75.RecorderTRef = 0x000000D3 THEN T97.Date_Time_ WHEN T75.RecorderTRef = 0x000000FF THEN T131.Date_Time_ WHEN T75.RecorderTRef = 0x000000D2 THEN T141._Date_Time ELSE CAST(NULL AS DATETIME) END >= ?) AND (CASE WHEN T75.RecorderTRef = 0x000000FD THEN T108._Date_Time WHEN T75.RecorderTRef = 0x00000103 THEN T109.Date_Time_ WHEN T75.RecorderTRef = 0x000000D1 THEN T119.Date_Time_ WHEN T75.RecorderTRef = 0x000000D3 THEN T97.Date_Time_ WHEN T75.RecorderTRef = 0x000000FF THEN T131.Date_Time_ WHEN T75.RecorderTRef = 0x000000D2 THEN T141._Date_Time ELSE CAST(NULL AS DATETIME) END <= ?) AND (CASE WHEN T75.RecorderTRef = 0x000000FD THEN CASE WHEN T108._Fld5746RRef IS NOT NULL THEN 0x000001BE END WHEN T75.RecorderTRef = 0x00000103 THEN CASE WHEN T109.Fld6155RRef IS NOT NULL THEN 0x000001B1 END WHEN T75.RecorderTRef = 0x000000D3 THEN CASE WHEN T97.Fld3452RRef IS NOT NULL THEN 0x000001B4 END WHEN T75.RecorderTRef = 0x000000FF THEN CASE WHEN T131.Fld5875RRef IS NOT NULL THEN 0x000001BF END WHEN T75.RecorderTRef = 0x000000D2 THEN CASE WHEN T141._Fld3367RRef IS NOT NULL THEN 0x000001B3 END ELSE CAST(NULL AS BINARY(4)) END = 0x000001B4 AND CASE WHEN T75.RecorderTRef = 0x000000FD THEN T108._Fld5746RRef WHEN T75.RecorderTRef = 0x00000103 THEN T109.Fld6155RRef WHEN T75.RecorderTRef = 0x000000D3 THEN T97.Fld3452RRef WHEN T75.RecorderTRef = 0x000000FF THEN T131.Fld5875RRef WHEN T75.RecorderTRef = 0x000000D2 THEN T141._Fld3367RRef ELSE CAST(NULL AS BINARY(16)) END IN (?)) AND (T88.IDRRef = ?)
  484. UNION ALL SELECT
  485. T142.MonthPeriod_,
  486. CAST(0.0 AS NUMERIC(27, 2)),
  487. T192.Fld12836RRef,
  488. T192.IDRRef,
  489. T142.Fld10491Receipt_,
  490. CAST(0.0 AS NUMERIC(21, 2)),
  491. T192.IDRRef,
  492. T192.Description_,
  493. T192.Description_,
  494. T192.Fld12836RRef,
  495. T201._Description,
  496. 4.0,
  497. T201._Description
  498. FROM (SELECT
  499. DATEADD(DAY,1.0 - 1,DATEADD(MONTH,CAST(DATEPART(MONTH,T143._Period) AS NUMERIC(4)) - 1,DATEADD(YEAR,(CAST(DATEPART(YEAR,T143._Period) AS NUMERIC(4)) - 2000) - 2000,{ts '4000-01-01 00:00:00'}))) AS MonthPeriod_,
  500. T143._RecorderTRef AS RecorderTRef,
  501. T143._RecorderRRef AS RecorderRRef,
  502. ISNULL(CAST(CAST(SUM(CASE WHEN T143._RecordKind = 0.0 THEN T143._Fld10491 ELSE 0.0 END) AS NUMERIC(27, 8)) AS NUMERIC(21, 2)),0.0) AS Fld10491Receipt_
  503. FROM dbo._AccumRg10486 T143
  504. WHERE (((T143._Fld595 = ?)) AND (EXISTS(SELECT
  505. 0x01 AS Q_001_F_000_
  506. FROM dbo._Reference98 T144
  507. INNER JOIN dbo._Reference21 T145
  508. ON (((T144._Fld1685 = ?) AND EXISTS(SELECT
  509. 0x01 AS Q_004_F_000_
  510. FROM dbo._InfoRg11709 T146
  511. WHERE ((T146._Fld595 = ?)) AND ((T146._Fld12065RRef = T144._IDRRef) AND (T146._Fld12066RRef = T145._IDRRef)))) AND T145._IDRRef IN
  512. (SELECT
  513. T147._Reference21_IDRRef AS Q_005_F_000RRef
  514. FROM dbo._Reference21_VT782 T147
  515. INNER JOIN dbo._InfoRg9937 T148
  516. ON ((T148._Fld9939_TYPE = 0x08 AND T148._Fld9939_RTRef = 0x00000095 AND T148._Fld9939_RRRef = ?) AND (T148._Fld9938_TYPE = T147._Fld784_TYPE AND T148._Fld9938_RTRef = T147._Fld784_RTRef AND T148._Fld9938_RRRef = T147._Fld784_RRRef))
  517. WHERE ((T147._Fld595 = ?)) AND (T148._Fld595 = ?)))
  518. WHERE ((T145._Fld595 = ?)) AND (CASE WHEN (T143._Fld10489_TYPE = 0x08 AND T143._Fld10489_RTRef = 0x0000006E) THEN CASE WHEN ((T143._Fld10489_TYPE <> 0x01) AND (CASE WHEN EXISTS(SELECT
  519. 0x01 AS Q_002_F_000_
  520. FROM dbo._InfoRg11710 T149
  521. WHERE ((T149._Fld595 = ?)) AND ((T149._Fld12072RRef = T145._IDRRef) AND (T149._Fld12073_TYPE = T143._Fld10489_TYPE AND T149._Fld12073_RTRef = T143._Fld10489_RTRef AND T149._Fld12073_RRRef = T143._Fld10489_RRRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  522. 0x01 AS Q_003_F_000_
  523. FROM dbo._InfoRg11715 T150
  524. WHERE ((T150._Fld595 = ?)) AND ((T150._Fld12199RRef = T145._IDRRef) AND T150._Fld12200_TYPE = T143._Fld10489_TYPE AND T150._Fld12200_RTRef = T143._Fld10489_RTRef AND (T150._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)) THEN 0x01 ELSE 0x00 END ELSE 0x00 END) = 0x01))) AND (T143._Period >= ? AND T143._Period <= ? AND T143._Active = 0x01 AND ((T143._Fld10487RRef = ?)) AND T143._RecordKind = ?)
  525. GROUP BY DATEADD(DAY,1.0 - 1,DATEADD(MONTH,CAST(DATEPART(MONTH,T143._Period) AS NUMERIC(4)) - 1,DATEADD(YEAR,(CAST(DATEPART(YEAR,T143._Period) AS NUMERIC(4)) - 2000) - 2000,{ts '4000-01-01 00:00:00'}))),
  526. T143._RecorderTRef,
  527. T143._RecorderRRef
  528. HAVING (ISNULL(CAST(CAST(SUM(CASE WHEN T143._RecordKind = 0.0 THEN T143._Fld10491 ELSE 0.0 END) AS NUMERIC(27, 8)) AS NUMERIC(21, 2)),0.0)) <> 0.0) T142
  529. LEFT OUTER JOIN dbo._Document253 T151
  530. ON (T142.RecorderTRef = 0x000000FD AND T142.RecorderRRef = T151._IDRRef) AND (T151._Fld595 = ?)
  531. LEFT OUTER JOIN (SELECT
  532. T153._IDRRef AS IDRRef,
  533. T153._Fld595 AS Fld595_,
  534. T153._Fld6145_TYPE AS Fld6145_TYPE,
  535. T153._Fld6145_RTRef AS Fld6145_RTRef,
  536. T153._Fld6145_RRRef AS Fld6145_RRRef,
  537. T153._Fld6155RRef AS Fld6155RRef,
  538. T153._Fld6139RRef AS Fld6139RRef
  539. FROM dbo._Document259 T153
  540. WHERE ((EXISTS(SELECT
  541. 1
  542. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  543. LEFT OUTER JOIN dbo._Reference42 T154
  544. ON ((T153._Fld6139RRef = T154._IDRRef)) AND (T154._Fld595 = ?)
  545. WHERE EXISTS(SELECT
  546. 0x01 AS Q_001_F_000_
  547. FROM dbo._Reference98 T155
  548. INNER JOIN dbo._Reference21 T156
  549. ON (((T155._Fld1685 = ?) AND EXISTS(SELECT
  550. 0x01 AS Q_004_F_000_
  551. FROM dbo._InfoRg11709 T157
  552. WHERE ((T157._Fld595 = ?)) AND ((T157._Fld12065RRef = T155._IDRRef) AND (T157._Fld12066RRef = T156._IDRRef)))) AND T156._IDRRef IN
  553. (SELECT
  554. T158._Reference21_IDRRef AS Q_005_F_000RRef
  555. FROM dbo._Reference21_VT782 T158
  556. INNER JOIN dbo._InfoRg9937 T159
  557. ON ((T159._Fld9939_TYPE = 0x08 AND T159._Fld9939_RTRef = 0x00000095 AND T159._Fld9939_RRRef = ?) AND (T159._Fld9938_TYPE = T158._Fld784_TYPE AND T159._Fld9938_RTRef = T158._Fld784_RTRef AND T159._Fld9938_RRRef = T158._Fld784_RRRef))
  558. WHERE ((T158._Fld595 = ?)) AND (T159._Fld595 = ?)))
  559. WHERE ((T156._Fld595 = ?)) AND ((CASE WHEN T154._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T154._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  560. 0x01 AS Q_002_F_000_
  561. FROM dbo._InfoRg11710 T160
  562. WHERE ((T160._Fld595 = ?)) AND ((T160._Fld12072RRef = T156._IDRRef) AND (T160._Fld12073_TYPE = CASE WHEN T154._Fld12836RRef IS NOT NULL THEN 0x08 END AND T160._Fld12073_RTRef = CASE WHEN T154._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T160._Fld12073_RRRef = T154._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  563. 0x01 AS Q_003_F_000_
  564. FROM dbo._InfoRg11715 T161
  565. WHERE ((T161._Fld595 = ?)) AND ((T161._Fld12199RRef = T156._IDRRef) AND T161._Fld12200_TYPE = CASE WHEN T154._Fld12836RRef IS NOT NULL THEN 0x08 END AND T161._Fld12200_RTRef = CASE WHEN T154._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T161._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T153._Fld595 = ?)) T152
  566. ON T142.RecorderTRef = 0x00000103 AND T142.RecorderRRef = T152.IDRRef
  567. LEFT OUTER JOIN (SELECT
  568. T163._IDRRef AS IDRRef,
  569. T163._Fld3273RRef AS Fld3273RRef,
  570. T163._Fld3279_TYPE AS Fld3279_TYPE,
  571. T163._Fld3279_RTRef AS Fld3279_RTRef,
  572. T163._Fld3279_RRRef AS Fld3279_RRRef,
  573. T163._Fld3289RRef AS Fld3289RRef,
  574. T163._Fld595 AS Fld595_,
  575. T163._Fld3291RRef AS Fld3291RRef
  576. FROM dbo._Document207 T163
  577. WHERE ((EXISTS(SELECT
  578. 0x01 AS Q_001_F_000_
  579. FROM dbo._Reference98 T164
  580. INNER JOIN dbo._Reference21 T165
  581. ON (((T164._Fld1685 = ?) AND EXISTS(SELECT
  582. 0x01 AS Q_006_F_000_
  583. FROM dbo._InfoRg11709 T166
  584. WHERE ((T166._Fld595 = ?)) AND ((T166._Fld12065RRef = T164._IDRRef) AND (T166._Fld12066RRef = T165._IDRRef)))) AND T165._IDRRef IN
  585. (SELECT
  586. T167._Reference21_IDRRef AS Q_007_F_000RRef
  587. FROM dbo._Reference21_VT782 T167
  588. INNER JOIN dbo._InfoRg9937 T168
  589. ON ((T168._Fld9939_TYPE = 0x08 AND T168._Fld9939_RTRef = 0x00000095 AND T168._Fld9939_RRRef = ?) AND (T168._Fld9938_TYPE = T167._Fld784_TYPE AND T168._Fld9938_RTRef = T167._Fld784_RTRef AND T168._Fld9938_RRRef = T167._Fld784_RRRef))
  590. WHERE ((T167._Fld595 = ?)) AND (T168._Fld595 = ?)))
  591. WHERE ((T165._Fld595 = ?)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  592. 0x01 AS Q_002_F_000_
  593. FROM dbo._InfoRg11710 T169
  594. WHERE ((T169._Fld595 = ?)) AND ((T169._Fld12072RRef = T165._IDRRef) AND (T169._Fld12073_TYPE = 0x08 AND T169._Fld12073_RTRef = 0x0000006E AND T169._Fld12073_RRRef = T163._Fld3289RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  595. 0x01 AS Q_003_F_000_
  596. FROM dbo._InfoRg11715 T170
  597. WHERE ((T170._Fld595 = ?)) AND ((T170._Fld12199RRef = T165._IDRRef) AND T170._Fld12200_TYPE = 0x08 AND T170._Fld12200_RTRef = 0x0000006E AND (T170._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) AND (0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  598. 0x01 AS Q_004_F_000_
  599. FROM dbo._InfoRg11710 T171
  600. WHERE ((T171._Fld595 = ?)) AND ((T171._Fld12072RRef = T165._IDRRef) AND (T171._Fld12073_TYPE = 0x08 AND T171._Fld12073_RTRef = 0x0000006E AND T171._Fld12073_RRRef = T163._Fld3291RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  601. 0x01 AS Q_005_F_000_
  602. FROM dbo._InfoRg11715 T172
  603. WHERE ((T172._Fld595 = ?)) AND ((T172._Fld12199RRef = T165._IDRRef) AND T172._Fld12200_TYPE = 0x08 AND T172._Fld12200_RTRef = 0x0000006E AND (T172._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) AND (T163._Fld595 = ?)) T162
  604. ON T142.RecorderTRef = 0x000000CF AND T142.RecorderRRef = T162.IDRRef
  605. LEFT OUTER JOIN (SELECT
  606. T174._Fld6057_TYPE AS Fld6057_TYPE,
  607. T174._Fld6057_RTRef AS Fld6057_RTRef,
  608. T174._Fld6057_RRRef AS Fld6057_RRRef,
  609. T174._IDRRef AS IDRRef,
  610. T174._Fld6051RRef AS Fld6051RRef,
  611. T174._Fld6064RRef AS Fld6064RRef,
  612. T174._Fld595 AS Fld595_,
  613. T174._Fld6072RRef AS Fld6072RRef
  614. FROM dbo._Document258 T174
  615. WHERE ((EXISTS(SELECT
  616. 0x01 AS Q_001_F_000_
  617. FROM dbo._Reference98 T175
  618. INNER JOIN dbo._Reference21 T176
  619. ON (((T175._Fld1685 = ?) AND EXISTS(SELECT
  620. 0x01 AS Q_004_F_000_
  621. FROM dbo._InfoRg11709 T177
  622. WHERE ((T177._Fld595 = ?)) AND ((T177._Fld12065RRef = T175._IDRRef) AND (T177._Fld12066RRef = T176._IDRRef)))) AND T176._IDRRef IN
  623. (SELECT
  624. T178._Reference21_IDRRef AS Q_005_F_000RRef
  625. FROM dbo._Reference21_VT782 T178
  626. INNER JOIN dbo._InfoRg9937 T179
  627. ON ((T179._Fld9939_TYPE = 0x08 AND T179._Fld9939_RTRef = 0x00000095 AND T179._Fld9939_RRRef = ?) AND (T179._Fld9938_TYPE = T178._Fld784_TYPE AND T179._Fld9938_RTRef = T178._Fld784_RTRef AND T179._Fld9938_RRRef = T178._Fld784_RRRef))
  628. WHERE ((T178._Fld595 = ?)) AND (T179._Fld595 = ?)))
  629. WHERE ((T176._Fld595 = ?)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  630. 0x01 AS Q_002_F_000_
  631. FROM dbo._InfoRg11710 T180
  632. WHERE ((T180._Fld595 = ?)) AND ((T180._Fld12072RRef = T176._IDRRef) AND (T180._Fld12073_TYPE = 0x08 AND T180._Fld12073_RTRef = 0x0000006E AND T180._Fld12073_RRRef = T174._Fld6064RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  633. 0x01 AS Q_003_F_000_
  634. FROM dbo._InfoRg11715 T181
  635. WHERE ((T181._Fld595 = ?)) AND ((T181._Fld12199RRef = T176._IDRRef) AND T181._Fld12200_TYPE = 0x08 AND T181._Fld12200_RTRef = 0x0000006E AND (T181._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) AND (T174._Fld595 = ?)) T173
  636. ON T142.RecorderTRef = 0x00000102 AND T142.RecorderRRef = T173.IDRRef
  637. LEFT OUTER JOIN (SELECT
  638. T183._Fld5855RRef AS Fld5855RRef,
  639. T183._IDRRef AS IDRRef,
  640. T183._Fld5860_TYPE AS Fld5860_TYPE,
  641. T183._Fld5860_RTRef AS Fld5860_RTRef,
  642. T183._Fld5860_RRRef AS Fld5860_RRRef,
  643. T183._Fld5875RRef AS Fld5875RRef,
  644. T183._Fld595 AS Fld595_
  645. FROM dbo._Document255 T183
  646. WHERE ((EXISTS(SELECT
  647. 1
  648. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  649. LEFT OUTER JOIN dbo._Reference42 T184
  650. ON ((T183._Fld5855RRef = T184._IDRRef)) AND (T184._Fld595 = ?)
  651. WHERE EXISTS(SELECT
  652. 0x01 AS Q_001_F_000_
  653. FROM dbo._Reference98 T185
  654. INNER JOIN dbo._Reference21 T186
  655. ON (((T185._Fld1685 = ?) AND EXISTS(SELECT
  656. 0x01 AS Q_004_F_000_
  657. FROM dbo._InfoRg11709 T187
  658. WHERE ((T187._Fld595 = ?)) AND ((T187._Fld12065RRef = T185._IDRRef) AND (T187._Fld12066RRef = T186._IDRRef)))) AND T186._IDRRef IN
  659. (SELECT
  660. T188._Reference21_IDRRef AS Q_005_F_000RRef
  661. FROM dbo._Reference21_VT782 T188
  662. INNER JOIN dbo._InfoRg9937 T189
  663. ON ((T189._Fld9939_TYPE = 0x08 AND T189._Fld9939_RTRef = 0x00000095 AND T189._Fld9939_RRRef = ?) AND (T189._Fld9938_TYPE = T188._Fld784_TYPE AND T189._Fld9938_RTRef = T188._Fld784_RTRef AND T189._Fld9938_RRRef = T188._Fld784_RRRef))
  664. WHERE ((T188._Fld595 = ?)) AND (T189._Fld595 = ?)))
  665. WHERE ((T186._Fld595 = ?)) AND ((CASE WHEN T184._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T184._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  666. 0x01 AS Q_002_F_000_
  667. FROM dbo._InfoRg11710 T190
  668. WHERE ((T190._Fld595 = ?)) AND ((T190._Fld12072RRef = T186._IDRRef) AND (T190._Fld12073_TYPE = CASE WHEN T184._Fld12836RRef IS NOT NULL THEN 0x08 END AND T190._Fld12073_RTRef = CASE WHEN T184._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T190._Fld12073_RRRef = T184._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  669. 0x01 AS Q_003_F_000_
  670. FROM dbo._InfoRg11715 T191
  671. WHERE ((T191._Fld595 = ?)) AND ((T191._Fld12199RRef = T186._IDRRef) AND T191._Fld12200_TYPE = CASE WHEN T184._Fld12836RRef IS NOT NULL THEN 0x08 END AND T191._Fld12200_RTRef = CASE WHEN T184._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T191._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T183._Fld595 = ?)) T182
  672. ON T142.RecorderTRef = 0x000000FF AND T142.RecorderRRef = T182.IDRRef
  673. LEFT OUTER JOIN (SELECT
  674. T193._IDRRef AS IDRRef,
  675. T193._Fld12836RRef AS Fld12836RRef,
  676. T193._Fld595 AS Fld595_,
  677. T193._Folder AS Folder_,
  678. T193._Description COLLATE Latin1_General_CI_AS AS Description_
  679. FROM dbo._Reference42 T193
  680. WHERE ((T193._IDRRef = ?) AND (((T193._Folder = 0x00) OR EXISTS(SELECT
  681. 0x01 AS Q_001_F_000_
  682. FROM dbo._Reference98 T194
  683. INNER JOIN dbo._Reference21 T195
  684. ON (((T194._Fld1685 = ?) AND EXISTS(SELECT
  685. 0x01 AS Q_004_F_000_
  686. FROM dbo._InfoRg11709 T196
  687. WHERE ((T196._Fld595 = ?)) AND ((T196._Fld12065RRef = T194._IDRRef) AND (T196._Fld12066RRef = T195._IDRRef)))) AND T195._IDRRef IN
  688. (SELECT
  689. T197._Reference21_IDRRef AS Q_005_F_000RRef
  690. FROM dbo._Reference21_VT782 T197
  691. INNER JOIN dbo._InfoRg9937 T198
  692. ON ((T198._Fld9939_TYPE = 0x08 AND T198._Fld9939_RTRef = 0x00000095 AND T198._Fld9939_RRRef = ?) AND (T198._Fld9938_TYPE = T197._Fld784_TYPE AND T198._Fld9938_RTRef = T197._Fld784_RTRef AND T198._Fld9938_RRRef = T197._Fld784_RRRef))
  693. WHERE ((T197._Fld595 = ?)) AND (T198._Fld595 = ?)))
  694. WHERE ((T195._Fld595 = ?)) AND ((CASE WHEN T193._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T193._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  695. 0x01 AS Q_002_F_000_
  696. FROM dbo._InfoRg11710 T199
  697. WHERE ((T199._Fld595 = ?)) AND ((T199._Fld12072RRef = T195._IDRRef) AND (T199._Fld12073_TYPE = CASE WHEN T193._Fld12836RRef IS NOT NULL THEN 0x08 END AND T199._Fld12073_RTRef = CASE WHEN T193._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T199._Fld12073_RRRef = T193._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  698. 0x01 AS Q_003_F_000_
  699. FROM dbo._InfoRg11715 T200
  700. WHERE ((T200._Fld595 = ?)) AND ((T200._Fld12199RRef = T195._IDRRef) AND T200._Fld12200_TYPE = CASE WHEN T193._Fld12836RRef IS NOT NULL THEN 0x08 END AND T200._Fld12200_RTRef = CASE WHEN T193._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T200._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T193._Fld595 = ?)) T192
  701. ON (CASE WHEN T142.RecorderTRef = 0x000000FD THEN T151._Fld5721RRef WHEN T142.RecorderTRef = 0x00000103 THEN T152.Fld6139RRef WHEN T142.RecorderTRef = 0x000000CF THEN T162.Fld3273RRef WHEN T142.RecorderTRef = 0x00000102 THEN T173.Fld6051RRef WHEN T142.RecorderTRef = 0x000000FF THEN T182.Fld5855RRef ELSE CAST(NULL AS BINARY(16)) END = T192.IDRRef)
  702. LEFT OUTER JOIN dbo._Reference28 T201
  703. ON (T192.Fld12836RRef = T201._IDRRef) AND (T201._Fld595 = ?)
  704. WHERE (NOT (((CASE WHEN T142.RecorderTRef = 0x000000FD THEN T151._Fld5727_TYPE WHEN T142.RecorderTRef = 0x00000103 THEN T152.Fld6145_TYPE WHEN T142.RecorderTRef = 0x000000CF THEN T162.Fld3279_TYPE WHEN T142.RecorderTRef = 0x00000102 THEN T173.Fld6057_TYPE WHEN T142.RecorderTRef = 0x000000FF THEN T182.Fld5860_TYPE ELSE CAST(NULL AS BINARY(1)) END = 0x08 AND CASE WHEN T142.RecorderTRef = 0x000000FD THEN T151._Fld5727_RTRef WHEN T142.RecorderTRef = 0x00000103 THEN T152.Fld6145_RTRef WHEN T142.RecorderTRef = 0x000000CF THEN T162.Fld3279_RTRef WHEN T142.RecorderTRef = 0x00000102 THEN T173.Fld6057_RTRef WHEN T142.RecorderTRef = 0x000000FF THEN T182.Fld5860_RTRef ELSE CAST(NULL AS BINARY(4)) END = 0x000000D3)))) AND ((CASE WHEN T142.RecorderTRef = 0x000000FD THEN CASE WHEN T151._Fld5746RRef IS NOT NULL THEN 0x000001BE END WHEN T142.RecorderTRef = 0x00000103 THEN CASE WHEN T152.Fld6155RRef IS NOT NULL THEN 0x000001B1 END WHEN T142.RecorderTRef = 0x00000102 THEN CASE WHEN T173.Fld6072RRef IS NOT NULL THEN 0x000001B0 END WHEN T142.RecorderTRef = 0x000000FF THEN CASE WHEN T182.Fld5875RRef IS NOT NULL THEN 0x000001BF END ELSE CAST(NULL AS BINARY(4)) END = 0x000001BF AND CASE WHEN T142.RecorderTRef = 0x000000FD THEN T151._Fld5746RRef WHEN T142.RecorderTRef = 0x00000103 THEN T152.Fld6155RRef WHEN T142.RecorderTRef = 0x00000102 THEN T173.Fld6072RRef WHEN T142.RecorderTRef = 0x000000FF THEN T182.Fld5875RRef ELSE CAST(NULL AS BINARY(16)) END = ?) OR (CASE WHEN T142.RecorderTRef = 0x000000FD THEN CASE WHEN T151._Fld5746RRef IS NOT NULL THEN 0x000001BE END WHEN T142.RecorderTRef = 0x00000103 THEN CASE WHEN T152.Fld6155RRef IS NOT NULL THEN 0x000001B1 END WHEN T142.RecorderTRef = 0x00000102 THEN CASE WHEN T173.Fld6072RRef IS NOT NULL THEN 0x000001B0 END WHEN T142.RecorderTRef = 0x000000FF THEN CASE WHEN T182.Fld5875RRef IS NOT NULL THEN 0x000001BF END ELSE CAST(NULL AS BINARY(4)) END = 0x000001B1 AND CASE WHEN T142.RecorderTRef = 0x000000FD THEN T151._Fld5746RRef WHEN T142.RecorderTRef = 0x00000103 THEN T152.Fld6155RRef WHEN T142.RecorderTRef = 0x00000102 THEN T173.Fld6072RRef WHEN T142.RecorderTRef = 0x000000FF THEN T182.Fld5875RRef ELSE CAST(NULL AS BINARY(16)) END = ?)) AND (T192.IDRRef = ?)
  705. UNION ALL SELECT
  706. DATEADD(DAY,1.0 - 1,DATEADD(MONTH,CAST(DATEPART(MONTH,T224.Date_Time_) AS NUMERIC(4)) - 1,DATEADD(YEAR,(CAST(DATEPART(YEAR,T224.Date_Time_) AS NUMERIC(4)) - 2000) - 2000,?))),
  707. CAST(0.0 AS NUMERIC(27, 2)),
  708. T215.Fld12836RRef,
  709. T215.IDRRef,
  710. CAST(NULL AS NUMERIC(21, 2)),
  711. T202.Fld10532Expense_,
  712. T215.IDRRef,
  713. T215.Description_,
  714. T215.Description_,
  715. T215.Fld12836RRef,
  716. T236._Description,
  717. 5.0,
  718. T236._Description
  719. FROM (SELECT
  720. T203._RecorderTRef AS RecorderTRef,
  721. T203._RecorderRRef AS RecorderRRef,
  722. T203._Fld10530_TYPE AS Fld10530_TYPE,
  723. T203._Fld10530_RTRef AS Fld10530_RTRef,
  724. T203._Fld10530_RRRef AS Fld10530_RRRef,
  725. CAST(SUM(CASE WHEN T203._RecordKind = 0.0 THEN 0.0 ELSE T203._Fld10532 END) AS NUMERIC(27, 8)) AS Fld10532Expense_
  726. FROM dbo._AccumRg10527 T203
  727. WHERE ((T203._Fld595 = ?)) AND (T203._Period <= ? AND T203._Active = 0x01 AND (((T203._Fld10528RRef = ?))) AND T203._RecordKind = ?)
  728. GROUP BY T203._RecorderTRef,
  729. T203._RecorderRRef,
  730. T203._Fld10530_TYPE,
  731. T203._Fld10530_RTRef,
  732. T203._Fld10530_RRRef
  733. HAVING (CAST(SUM(CASE WHEN T203._RecordKind = 0.0 THEN 0.0 ELSE T203._Fld10532 END) AS NUMERIC(27, 8))) <> 0.0) T202
  734. LEFT OUTER JOIN (SELECT
  735. T205._IDRRef AS IDRRef,
  736. T205._Fld3438RRef AS Fld3438RRef,
  737. T205._Fld595 AS Fld595_
  738. FROM dbo._Document211 T205
  739. WHERE ((EXISTS(SELECT
  740. 1
  741. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  742. LEFT OUTER JOIN dbo._Reference42 T206
  743. ON ((T205._Fld3438RRef = T206._IDRRef)) AND (T206._Fld595 = ?)
  744. WHERE EXISTS(SELECT
  745. 0x01 AS Q_001_F_000_
  746. FROM dbo._Reference98 T207
  747. INNER JOIN dbo._Reference21 T208
  748. ON (((T207._Fld1685 = ?) AND EXISTS(SELECT
  749. 0x01 AS Q_004_F_000_
  750. FROM dbo._InfoRg11709 T209
  751. WHERE ((T209._Fld595 = ?)) AND ((T209._Fld12065RRef = T207._IDRRef) AND (T209._Fld12066RRef = T208._IDRRef)))) AND T208._IDRRef IN
  752. (SELECT
  753. T210._Reference21_IDRRef AS Q_005_F_000RRef
  754. FROM dbo._Reference21_VT782 T210
  755. INNER JOIN dbo._InfoRg9937 T211
  756. ON ((T211._Fld9939_TYPE = 0x08 AND T211._Fld9939_RTRef = 0x00000095 AND T211._Fld9939_RRRef = ?) AND (T211._Fld9938_TYPE = T210._Fld784_TYPE AND T211._Fld9938_RTRef = T210._Fld784_RTRef AND T211._Fld9938_RRRef = T210._Fld784_RRRef))
  757. WHERE ((T210._Fld595 = ?)) AND (T211._Fld595 = ?)))
  758. WHERE ((T208._Fld595 = ?)) AND ((CASE WHEN T206._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T206._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  759. 0x01 AS Q_002_F_000_
  760. FROM dbo._InfoRg11710 T212
  761. WHERE ((T212._Fld595 = ?)) AND ((T212._Fld12072RRef = T208._IDRRef) AND (T212._Fld12073_TYPE = CASE WHEN T206._Fld12836RRef IS NOT NULL THEN 0x08 END AND T212._Fld12073_RTRef = CASE WHEN T206._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T212._Fld12073_RRRef = T206._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  762. 0x01 AS Q_003_F_000_
  763. FROM dbo._InfoRg11715 T213
  764. WHERE ((T213._Fld595 = ?)) AND ((T213._Fld12199RRef = T208._IDRRef) AND T213._Fld12200_TYPE = CASE WHEN T206._Fld12836RRef IS NOT NULL THEN 0x08 END AND T213._Fld12200_RTRef = CASE WHEN T206._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T213._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T205._Fld595 = ?)) T204
  765. ON T202.Fld10530_TYPE = 0x08 AND T202.Fld10530_RTRef = 0x000000D3 AND T202.Fld10530_RRRef = T204.IDRRef
  766. LEFT OUTER JOIN dbo._Document210 T214
  767. ON (T202.Fld10530_TYPE = 0x08 AND T202.Fld10530_RTRef = 0x000000D2 AND T202.Fld10530_RRRef = T214._IDRRef) AND (T214._Fld595 = ?)
  768. LEFT OUTER JOIN (SELECT
  769. T216._IDRRef AS IDRRef,
  770. T216._Fld12836RRef AS Fld12836RRef,
  771. T216._Fld595 AS Fld595_,
  772. T216._Folder AS Folder_,
  773. T216._Description COLLATE Latin1_General_CI_AS AS Description_
  774. FROM dbo._Reference42 T216
  775. WHERE ((T216._IDRRef = ?) AND (((T216._Folder = 0x00) OR EXISTS(SELECT
  776. 0x01 AS Q_001_F_000_
  777. FROM dbo._Reference98 T217
  778. INNER JOIN dbo._Reference21 T218
  779. ON (((T217._Fld1685 = ?) AND EXISTS(SELECT
  780. 0x01 AS Q_004_F_000_
  781. FROM dbo._InfoRg11709 T219
  782. WHERE ((T219._Fld595 = ?)) AND ((T219._Fld12065RRef = T217._IDRRef) AND (T219._Fld12066RRef = T218._IDRRef)))) AND T218._IDRRef IN
  783. (SELECT
  784. T220._Reference21_IDRRef AS Q_005_F_000RRef
  785. FROM dbo._Reference21_VT782 T220
  786. INNER JOIN dbo._InfoRg9937 T221
  787. ON ((T221._Fld9939_TYPE = 0x08 AND T221._Fld9939_RTRef = 0x00000095 AND T221._Fld9939_RRRef = ?) AND (T221._Fld9938_TYPE = T220._Fld784_TYPE AND T221._Fld9938_RTRef = T220._Fld784_RTRef AND T221._Fld9938_RRRef = T220._Fld784_RRRef))
  788. WHERE ((T220._Fld595 = ?)) AND (T221._Fld595 = ?)))
  789. WHERE ((T218._Fld595 = ?)) AND ((CASE WHEN T216._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T216._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  790. 0x01 AS Q_002_F_000_
  791. FROM dbo._InfoRg11710 T222
  792. WHERE ((T222._Fld595 = ?)) AND ((T222._Fld12072RRef = T218._IDRRef) AND (T222._Fld12073_TYPE = CASE WHEN T216._Fld12836RRef IS NOT NULL THEN 0x08 END AND T222._Fld12073_RTRef = CASE WHEN T216._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T222._Fld12073_RRRef = T216._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  793. 0x01 AS Q_003_F_000_
  794. FROM dbo._InfoRg11715 T223
  795. WHERE ((T223._Fld595 = ?)) AND ((T223._Fld12199RRef = T218._IDRRef) AND T223._Fld12200_TYPE = CASE WHEN T216._Fld12836RRef IS NOT NULL THEN 0x08 END AND T223._Fld12200_RTRef = CASE WHEN T216._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T223._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T216._Fld595 = ?)) T215
  796. ON (CASE WHEN T202.Fld10530_TYPE = 0x08 AND T202.Fld10530_RTRef = 0x000000D3 THEN T204.Fld3438RRef WHEN T202.Fld10530_TYPE = 0x08 AND T202.Fld10530_RTRef = 0x000000D2 THEN T214._Fld3343RRef ELSE CAST(NULL AS BINARY(16)) END = T215.IDRRef)
  797. LEFT OUTER JOIN (SELECT
  798. T225._IDRRef AS IDRRef,
  799. T225._Fld3325_TYPE AS Fld3325_TYPE,
  800. T225._Fld3325_RTRef AS Fld3325_RTRef,
  801. T225._Fld3325_RRRef AS Fld3325_RRRef,
  802. T225._Fld595 AS Fld595_,
  803. T225._Date_Time AS Date_Time_
  804. FROM dbo._Document209 T225
  805. WHERE ((EXISTS(SELECT
  806. 1
  807. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  808. LEFT OUTER JOIN dbo._Document211 T226
  809. ON (T225._Fld3325_TYPE = 0x08 AND T225._Fld3325_RTRef = 0x000000D3 AND T225._Fld3325_RRRef = T226._IDRRef) AND (T226._Fld595 = ?)
  810. LEFT OUTER JOIN dbo._Document210 T227
  811. ON (T225._Fld3325_TYPE = 0x08 AND T225._Fld3325_RTRef = 0x000000D2 AND T225._Fld3325_RRRef = T227._IDRRef) AND (T227._Fld595 = ?)
  812. LEFT OUTER JOIN dbo._Reference42 T228
  813. ON ((CASE WHEN T225._Fld3325_TYPE = 0x08 AND T225._Fld3325_RTRef = 0x000000D3 THEN T226._Fld3438RRef WHEN T225._Fld3325_TYPE = 0x08 AND T225._Fld3325_RTRef = 0x000000D2 THEN T227._Fld3343RRef ELSE CAST(NULL AS BINARY(16)) END = T228._IDRRef)) AND (T228._Fld595 = ?)
  814. WHERE EXISTS(SELECT
  815. 0x01 AS Q_001_F_000_
  816. FROM dbo._Reference98 T229
  817. INNER JOIN dbo._Reference21 T230
  818. ON (((T229._Fld1685 = ?) AND EXISTS(SELECT
  819. 0x01 AS Q_004_F_000_
  820. FROM dbo._InfoRg11709 T231
  821. WHERE ((T231._Fld595 = ?)) AND ((T231._Fld12065RRef = T229._IDRRef) AND (T231._Fld12066RRef = T230._IDRRef)))) AND T230._IDRRef IN
  822. (SELECT
  823. T232._Reference21_IDRRef AS Q_005_F_000RRef
  824. FROM dbo._Reference21_VT782 T232
  825. INNER JOIN dbo._InfoRg9937 T233
  826. ON ((T233._Fld9939_TYPE = 0x08 AND T233._Fld9939_RTRef = 0x00000095 AND T233._Fld9939_RRRef = ?) AND (T233._Fld9938_TYPE = T232._Fld784_TYPE AND T233._Fld9938_RTRef = T232._Fld784_RTRef AND T233._Fld9938_RRRef = T232._Fld784_RRRef))
  827. WHERE ((T232._Fld595 = ?)) AND (T233._Fld595 = ?)))
  828. WHERE ((T230._Fld595 = ?)) AND ((CASE WHEN T228._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T228._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  829. 0x01 AS Q_002_F_000_
  830. FROM dbo._InfoRg11710 T234
  831. WHERE ((T234._Fld595 = ?)) AND ((T234._Fld12072RRef = T230._IDRRef) AND (T234._Fld12073_TYPE = CASE WHEN T228._Fld12836RRef IS NOT NULL THEN 0x08 END AND T234._Fld12073_RTRef = CASE WHEN T228._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T234._Fld12073_RRRef = T228._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  832. 0x01 AS Q_003_F_000_
  833. FROM dbo._InfoRg11715 T235
  834. WHERE ((T235._Fld595 = ?)) AND ((T235._Fld12199RRef = T230._IDRRef) AND T235._Fld12200_TYPE = CASE WHEN T228._Fld12836RRef IS NOT NULL THEN 0x08 END AND T235._Fld12200_RTRef = CASE WHEN T228._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T235._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T225._Fld595 = ?)) T224
  835. ON T202.RecorderTRef = 0x000000D1 AND T202.RecorderRRef = T224.IDRRef
  836. LEFT OUTER JOIN dbo._Reference28 T236
  837. ON (T215.Fld12836RRef = T236._IDRRef) AND (T236._Fld595 = ?)
  838. LEFT OUTER JOIN dbo._Document253 T237
  839. ON (T202.RecorderTRef = 0x000000FD AND T202.RecorderRRef = T237._IDRRef) AND (T237._Fld595 = ?)
  840. LEFT OUTER JOIN (SELECT
  841. T239._IDRRef AS IDRRef,
  842. T239._Date_Time AS Date_Time_,
  843. T239._Fld595 AS Fld595_,
  844. T239._Fld6139RRef AS Fld6139RRef
  845. FROM dbo._Document259 T239
  846. WHERE ((EXISTS(SELECT
  847. 1
  848. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  849. LEFT OUTER JOIN dbo._Reference42 T240
  850. ON ((T239._Fld6139RRef = T240._IDRRef)) AND (T240._Fld595 = ?)
  851. WHERE EXISTS(SELECT
  852. 0x01 AS Q_001_F_000_
  853. FROM dbo._Reference98 T241
  854. INNER JOIN dbo._Reference21 T242
  855. ON (((T241._Fld1685 = ?) AND EXISTS(SELECT
  856. 0x01 AS Q_004_F_000_
  857. FROM dbo._InfoRg11709 T243
  858. WHERE ((T243._Fld595 = ?)) AND ((T243._Fld12065RRef = T241._IDRRef) AND (T243._Fld12066RRef = T242._IDRRef)))) AND T242._IDRRef IN
  859. (SELECT
  860. T244._Reference21_IDRRef AS Q_005_F_000RRef
  861. FROM dbo._Reference21_VT782 T244
  862. INNER JOIN dbo._InfoRg9937 T245
  863. ON ((T245._Fld9939_TYPE = 0x08 AND T245._Fld9939_RTRef = 0x00000095 AND T245._Fld9939_RRRef = ?) AND (T245._Fld9938_TYPE = T244._Fld784_TYPE AND T245._Fld9938_RTRef = T244._Fld784_RTRef AND T245._Fld9938_RRRef = T244._Fld784_RRRef))
  864. WHERE ((T244._Fld595 = ?)) AND (T245._Fld595 = ?)))
  865. WHERE ((T242._Fld595 = ?)) AND ((CASE WHEN T240._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T240._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  866. 0x01 AS Q_002_F_000_
  867. FROM dbo._InfoRg11710 T246
  868. WHERE ((T246._Fld595 = ?)) AND ((T246._Fld12072RRef = T242._IDRRef) AND (T246._Fld12073_TYPE = CASE WHEN T240._Fld12836RRef IS NOT NULL THEN 0x08 END AND T246._Fld12073_RTRef = CASE WHEN T240._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T246._Fld12073_RRRef = T240._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  869. 0x01 AS Q_003_F_000_
  870. FROM dbo._InfoRg11715 T247
  871. WHERE ((T247._Fld595 = ?)) AND ((T247._Fld12199RRef = T242._IDRRef) AND T247._Fld12200_TYPE = CASE WHEN T240._Fld12836RRef IS NOT NULL THEN 0x08 END AND T247._Fld12200_RTRef = CASE WHEN T240._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T247._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T239._Fld595 = ?)) T238
  872. ON T202.RecorderTRef = 0x00000103 AND T202.RecorderRRef = T238.IDRRef
  873. LEFT OUTER JOIN (SELECT
  874. T249._Date_Time AS Date_Time_,
  875. T249._IDRRef AS IDRRef,
  876. T249._Fld3438RRef AS Fld3438RRef,
  877. T249._Fld595 AS Fld595_
  878. FROM dbo._Document211 T249
  879. WHERE ((EXISTS(SELECT
  880. 1
  881. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  882. LEFT OUTER JOIN dbo._Reference42 T250
  883. ON ((T249._Fld3438RRef = T250._IDRRef)) AND (T250._Fld595 = ?)
  884. WHERE EXISTS(SELECT
  885. 0x01 AS Q_001_F_000_
  886. FROM dbo._Reference98 T251
  887. INNER JOIN dbo._Reference21 T252
  888. ON (((T251._Fld1685 = ?) AND EXISTS(SELECT
  889. 0x01 AS Q_004_F_000_
  890. FROM dbo._InfoRg11709 T253
  891. WHERE ((T253._Fld595 = ?)) AND ((T253._Fld12065RRef = T251._IDRRef) AND (T253._Fld12066RRef = T252._IDRRef)))) AND T252._IDRRef IN
  892. (SELECT
  893. T254._Reference21_IDRRef AS Q_005_F_000RRef
  894. FROM dbo._Reference21_VT782 T254
  895. INNER JOIN dbo._InfoRg9937 T255
  896. ON ((T255._Fld9939_TYPE = 0x08 AND T255._Fld9939_RTRef = 0x00000095 AND T255._Fld9939_RRRef = ?) AND (T255._Fld9938_TYPE = T254._Fld784_TYPE AND T255._Fld9938_RTRef = T254._Fld784_RTRef AND T255._Fld9938_RRRef = T254._Fld784_RRRef))
  897. WHERE ((T254._Fld595 = ?)) AND (T255._Fld595 = ?)))
  898. WHERE ((T252._Fld595 = ?)) AND ((CASE WHEN T250._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T250._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  899. 0x01 AS Q_002_F_000_
  900. FROM dbo._InfoRg11710 T256
  901. WHERE ((T256._Fld595 = ?)) AND ((T256._Fld12072RRef = T252._IDRRef) AND (T256._Fld12073_TYPE = CASE WHEN T250._Fld12836RRef IS NOT NULL THEN 0x08 END AND T256._Fld12073_RTRef = CASE WHEN T250._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T256._Fld12073_RRRef = T250._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  902. 0x01 AS Q_003_F_000_
  903. FROM dbo._InfoRg11715 T257
  904. WHERE ((T257._Fld595 = ?)) AND ((T257._Fld12199RRef = T252._IDRRef) AND T257._Fld12200_TYPE = CASE WHEN T250._Fld12836RRef IS NOT NULL THEN 0x08 END AND T257._Fld12200_RTRef = CASE WHEN T250._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T257._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T249._Fld595 = ?)) T248
  905. ON T202.RecorderTRef = 0x000000D3 AND T202.RecorderRRef = T248.IDRRef
  906. LEFT OUTER JOIN (SELECT
  907. T259._Fld5855RRef AS Fld5855RRef,
  908. T259._IDRRef AS IDRRef,
  909. T259._Date_Time AS Date_Time_,
  910. T259._Fld595 AS Fld595_
  911. FROM dbo._Document255 T259
  912. WHERE ((EXISTS(SELECT
  913. 1
  914. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  915. LEFT OUTER JOIN dbo._Reference42 T260
  916. ON ((T259._Fld5855RRef = T260._IDRRef)) AND (T260._Fld595 = ?)
  917. WHERE EXISTS(SELECT
  918. 0x01 AS Q_001_F_000_
  919. FROM dbo._Reference98 T261
  920. INNER JOIN dbo._Reference21 T262
  921. ON (((T261._Fld1685 = ?) AND EXISTS(SELECT
  922. 0x01 AS Q_004_F_000_
  923. FROM dbo._InfoRg11709 T263
  924. WHERE ((T263._Fld595 = ?)) AND ((T263._Fld12065RRef = T261._IDRRef) AND (T263._Fld12066RRef = T262._IDRRef)))) AND T262._IDRRef IN
  925. (SELECT
  926. T264._Reference21_IDRRef AS Q_005_F_000RRef
  927. FROM dbo._Reference21_VT782 T264
  928. INNER JOIN dbo._InfoRg9937 T265
  929. ON ((T265._Fld9939_TYPE = 0x08 AND T265._Fld9939_RTRef = 0x00000095 AND T265._Fld9939_RRRef = ?) AND (T265._Fld9938_TYPE = T264._Fld784_TYPE AND T265._Fld9938_RTRef = T264._Fld784_RTRef AND T265._Fld9938_RRRef = T264._Fld784_RRRef))
  930. WHERE ((T264._Fld595 = ?)) AND (T265._Fld595 = ?)))
  931. WHERE ((T262._Fld595 = ?)) AND ((CASE WHEN T260._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T260._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  932. 0x01 AS Q_002_F_000_
  933. FROM dbo._InfoRg11710 T266
  934. WHERE ((T266._Fld595 = ?)) AND ((T266._Fld12072RRef = T262._IDRRef) AND (T266._Fld12073_TYPE = CASE WHEN T260._Fld12836RRef IS NOT NULL THEN 0x08 END AND T266._Fld12073_RTRef = CASE WHEN T260._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T266._Fld12073_RRRef = T260._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  935. 0x01 AS Q_003_F_000_
  936. FROM dbo._InfoRg11715 T267
  937. WHERE ((T267._Fld595 = ?)) AND ((T267._Fld12199RRef = T262._IDRRef) AND T267._Fld12200_TYPE = CASE WHEN T260._Fld12836RRef IS NOT NULL THEN 0x08 END AND T267._Fld12200_RTRef = CASE WHEN T260._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T267._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T259._Fld595 = ?)) T258
  938. ON T202.RecorderTRef = 0x000000FF AND T202.RecorderRRef = T258.IDRRef
  939. LEFT OUTER JOIN dbo._Document210 T268
  940. ON (T202.RecorderTRef = 0x000000D2 AND T202.RecorderRRef = T268._IDRRef) AND (T268._Fld595 = ?)
  941. WHERE (CASE WHEN T202.RecorderTRef = 0x000000FD THEN T237._Date_Time WHEN T202.RecorderTRef = 0x00000103 THEN T238.Date_Time_ WHEN T202.RecorderTRef = 0x000000D1 THEN T224.Date_Time_ WHEN T202.RecorderTRef = 0x000000D3 THEN T248.Date_Time_ WHEN T202.RecorderTRef = 0x000000FF THEN T258.Date_Time_ WHEN T202.RecorderTRef = 0x000000D2 THEN T268._Date_Time ELSE CAST(NULL AS DATETIME) END >= ?) AND (CASE WHEN T202.RecorderTRef = 0x000000FD THEN T237._Date_Time WHEN T202.RecorderTRef = 0x00000103 THEN T238.Date_Time_ WHEN T202.RecorderTRef = 0x000000D1 THEN T224.Date_Time_ WHEN T202.RecorderTRef = 0x000000D3 THEN T248.Date_Time_ WHEN T202.RecorderTRef = 0x000000FF THEN T258.Date_Time_ WHEN T202.RecorderTRef = 0x000000D2 THEN T268._Date_Time ELSE CAST(NULL AS DATETIME) END <= ?) AND (T202.RecorderTRef = 0x000000D1) AND (T215.IDRRef = ?)
  942. "
  943.  
  944. 17469982=Duration,7=Execs,Sql="INSERT INTO #tt 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_005RRef) SELECT
  945. T1.Fld11293_TYPE,
  946. T1.Fld11293_RTRef,
  947. T1.Fld11293_RRRef,
  948. T1.Fld11295RRef,
  949. (T1.Fld11302Turnover_ - T1.Fld11303Turnover_),
  950. T65.IDRRef,
  951. CAST(0.0 AS NUMERIC(21, 2)),
  952. T65.Fld12836RRef
  953. FROM (SELECT
  954. T2._Fld11293_TYPE AS Fld11293_TYPE,
  955. T2._Fld11293_RTRef AS Fld11293_RTRef,
  956. T2._Fld11293_RRRef AS Fld11293_RRRef,
  957. T2._Fld11295RRef AS Fld11295RRef,
  958. CAST(SUM(T2._Fld11303) AS NUMERIC(33, 8)) AS Fld11303Turnover_,
  959. CAST(SUM(T2._Fld11302) AS NUMERIC(33, 8)) AS Fld11302Turnover_
  960. FROM dbo._AccumRgTn11305 T2
  961. WHERE (((T2._Fld595 = ?)) AND (EXISTS(SELECT
  962. 1
  963. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  964. LEFT OUTER JOIN dbo._Document233 T3
  965. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000E9 AND T2._Fld11293_RRRef = T3._IDRRef) AND (T3._Fld595 = ?)
  966. LEFT OUTER JOIN dbo._Document212 T4
  967. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D4 AND T2._Fld11293_RRRef = T4._IDRRef) AND (T4._Fld595 = ?)
  968. LEFT OUTER JOIN dbo._Document234 T5
  969. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000EA AND T2._Fld11293_RRRef = T5._IDRRef) AND (T5._Fld595 = ?)
  970. LEFT OUTER JOIN dbo._Document263 T6
  971. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x00000107 AND T2._Fld11293_RRRef = T6._IDRRef) AND (T6._Fld595 = ?)
  972. LEFT OUTER JOIN dbo._Document216 T7
  973. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D8 AND T2._Fld11293_RRRef = T7._IDRRef) AND (T7._Fld595 = ?)
  974. LEFT OUTER JOIN dbo._Document215 T8
  975. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D7 AND T2._Fld11293_RRRef = T8._IDRRef) AND (T8._Fld595 = ?)
  976. LEFT OUTER JOIN dbo._Document213 T9
  977. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D5 AND T2._Fld11293_RRRef = T9._IDRRef) AND (T9._Fld595 = ?)
  978. LEFT OUTER JOIN dbo._Document199 T10
  979. ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000C7 AND T2._Fld11293_RRRef = T10._IDRRef) AND (T10._Fld595 = ?)
  980. LEFT OUTER JOIN dbo._Reference42 T11
  981. 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 = ?)
  982. WHERE EXISTS(SELECT
  983. 0x01 AS Q_001_F_000_
  984. FROM dbo._Reference98 T12
  985. INNER JOIN dbo._Reference21 T13
  986. ON (((T12._Fld1685 = ?) AND EXISTS(SELECT
  987. 0x01 AS Q_004_F_000_
  988. FROM dbo._InfoRg11709 T14
  989. WHERE ((T14._Fld595 = ?)) AND ((T14._Fld12065RRef = T12._IDRRef) AND (T14._Fld12066RRef = T13._IDRRef)))) AND T13._IDRRef IN
  990. (SELECT
  991. T15._Reference21_IDRRef AS Q_005_F_000RRef
  992. FROM dbo._Reference21_VT782 T15
  993. INNER JOIN dbo._InfoRg9937 T16
  994. ON ((T16._Fld9939_TYPE = 0x08 AND T16._Fld9939_RTRef = 0x00000095 AND T16._Fld9939_RRRef = ?) AND (T16._Fld9938_TYPE = T15._Fld784_TYPE AND T16._Fld9938_RTRef = T15._Fld784_RTRef AND T16._Fld9938_RRRef = T15._Fld784_RRRef))
  995. WHERE ((T15._Fld595 = ?)) AND (T16._Fld595 = ?)))
  996. WHERE ((T13._Fld595 = ?)) 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
  997. 0x01 AS Q_002_F_000_
  998. FROM dbo._InfoRg11710 T17
  999. WHERE ((T17._Fld595 = ?)) 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._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T17._Fld12073_RRRef = T11._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1000. 0x01 AS Q_003_F_000_
  1001. FROM dbo._InfoRg11715 T18
  1002. WHERE ((T18._Fld595 = ?)) AND ((T18._Fld12199RRef = T13._IDRRef) AND T18._Fld12200_TYPE = CASE WHEN T11._Fld12836RRef IS NOT NULL THEN 0x08 END AND T18._Fld12200_RTRef = CASE WHEN T11._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T18._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T2._Period >= ? AND T2._Period < ? AND (T2._Fld11303 <> ? OR T2._Fld11302 <> ?))
  1003. GROUP BY T2._Fld11293_TYPE,
  1004. T2._Fld11293_RTRef,
  1005. T2._Fld11293_RRRef,
  1006. T2._Fld11295RRef
  1007. HAVING (CAST(SUM(T2._Fld11303) AS NUMERIC(33, 8))) <> 0.0 OR (CAST(SUM(T2._Fld11302) AS NUMERIC(33, 8))) <> 0.0) T1
  1008. LEFT OUTER JOIN (SELECT
  1009. T20._IDRRef AS IDRRef,
  1010. T20._Fld4625RRef AS Fld4625RRef,
  1011. T20._Fld595 AS Fld595_
  1012. FROM dbo._Document233 T20
  1013. WHERE ((EXISTS(SELECT
  1014. 1
  1015. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1016. LEFT OUTER JOIN dbo._Reference42 T21
  1017. ON ((T20._Fld4625RRef = T21._IDRRef)) AND (T21._Fld595 = ?)
  1018. WHERE EXISTS(SELECT
  1019. 0x01 AS Q_001_F_000_
  1020. FROM dbo._Reference98 T22
  1021. INNER JOIN dbo._Reference21 T23
  1022. ON (((T22._Fld1685 = ?) AND EXISTS(SELECT
  1023. 0x01 AS Q_004_F_000_
  1024. FROM dbo._InfoRg11709 T24
  1025. WHERE ((T24._Fld595 = ?)) AND ((T24._Fld12065RRef = T22._IDRRef) AND (T24._Fld12066RRef = T23._IDRRef)))) AND T23._IDRRef IN
  1026. (SELECT
  1027. T25._Reference21_IDRRef AS Q_005_F_000RRef
  1028. FROM dbo._Reference21_VT782 T25
  1029. INNER JOIN dbo._InfoRg9937 T26
  1030. ON ((T26._Fld9939_TYPE = 0x08 AND T26._Fld9939_RTRef = 0x00000095 AND T26._Fld9939_RRRef = ?) AND (T26._Fld9938_TYPE = T25._Fld784_TYPE AND T26._Fld9938_RTRef = T25._Fld784_RTRef AND T26._Fld9938_RRRef = T25._Fld784_RRRef))
  1031. WHERE ((T25._Fld595 = ?)) AND (T26._Fld595 = ?)))
  1032. WHERE ((T23._Fld595 = ?)) AND ((CASE WHEN T21._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1033. 0x01 AS Q_002_F_000_
  1034. FROM dbo._InfoRg11710 T27
  1035. WHERE ((T27._Fld595 = ?)) AND ((T27._Fld12072RRef = T23._IDRRef) AND (T27._Fld12073_TYPE = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x08 END AND T27._Fld12073_RTRef = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T27._Fld12073_RRRef = T21._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1036. 0x01 AS Q_003_F_000_
  1037. FROM dbo._InfoRg11715 T28
  1038. WHERE ((T28._Fld595 = ?)) AND ((T28._Fld12199RRef = T23._IDRRef) AND T28._Fld12200_TYPE = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x08 END AND T28._Fld12200_RTRef = CASE WHEN T21._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T28._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T20._Fld595 = ?)) T19
  1039. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000E9 AND T1.Fld11293_RRRef = T19.IDRRef
  1040. LEFT OUTER JOIN dbo._Document212 T29
  1041. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D4 AND T1.Fld11293_RRRef = T29._IDRRef) AND (T29._Fld595 = ?)
  1042. LEFT OUTER JOIN (SELECT
  1043. T31._IDRRef AS IDRRef,
  1044. T31._Fld4779RRef AS Fld4779RRef,
  1045. T31._Fld595 AS Fld595_,
  1046. T31._Fld4774RRef AS Fld4774RRef
  1047. FROM dbo._Document234 T31
  1048. WHERE ((EXISTS(SELECT
  1049. 1
  1050. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1051. LEFT OUTER JOIN dbo._Reference42 T32
  1052. ON ((T31._Fld4774RRef = T32._IDRRef)) AND (T32._Fld595 = ?)
  1053. WHERE EXISTS(SELECT
  1054. 0x01 AS Q_001_F_000_
  1055. FROM dbo._Reference98 T33
  1056. INNER JOIN dbo._Reference21 T34
  1057. ON (((T33._Fld1685 = ?) AND EXISTS(SELECT
  1058. 0x01 AS Q_006_F_000_
  1059. FROM dbo._InfoRg11709 T35
  1060. WHERE ((T35._Fld595 = ?)) AND ((T35._Fld12065RRef = T33._IDRRef) AND (T35._Fld12066RRef = T34._IDRRef)))) AND T34._IDRRef IN
  1061. (SELECT
  1062. T36._Reference21_IDRRef AS Q_007_F_000RRef
  1063. FROM dbo._Reference21_VT782 T36
  1064. INNER JOIN dbo._InfoRg9937 T37
  1065. ON ((T37._Fld9939_TYPE = 0x08 AND T37._Fld9939_RTRef = 0x00000095 AND T37._Fld9939_RRRef = ?) AND (T37._Fld9938_TYPE = T36._Fld784_TYPE AND T37._Fld9938_RTRef = T36._Fld784_RTRef AND T37._Fld9938_RRRef = T36._Fld784_RRRef))
  1066. WHERE ((T36._Fld595 = ?)) AND (T37._Fld595 = ?)))
  1067. WHERE ((T34._Fld595 = ?)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1068. 0x01 AS Q_002_F_000_
  1069. FROM dbo._InfoRg11710 T38
  1070. WHERE ((T38._Fld595 = ?)) AND ((T38._Fld12072RRef = T34._IDRRef) AND (T38._Fld12073_TYPE = 0x08 AND T38._Fld12073_RTRef = 0x0000001C AND T38._Fld12073_RRRef = T31._Fld4779RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1071. 0x01 AS Q_003_F_000_
  1072. FROM dbo._InfoRg11715 T39
  1073. WHERE ((T39._Fld595 = ?)) AND ((T39._Fld12199RRef = T34._IDRRef) AND T39._Fld12200_TYPE = 0x08 AND T39._Fld12200_RTRef = 0x0000001C AND (T39._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) AND (CASE WHEN T32._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1074. 0x01 AS Q_004_F_000_
  1075. FROM dbo._InfoRg11710 T40
  1076. WHERE ((T40._Fld595 = ?)) AND ((T40._Fld12072RRef = T34._IDRRef) AND (T40._Fld12073_TYPE = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x08 END AND T40._Fld12073_RTRef = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T40._Fld12073_RRRef = T32._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1077. 0x01 AS Q_005_F_000_
  1078. FROM dbo._InfoRg11715 T41
  1079. WHERE ((T41._Fld595 = ?)) AND ((T41._Fld12199RRef = T34._IDRRef) AND T41._Fld12200_TYPE = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x08 END AND T41._Fld12200_RTRef = CASE WHEN T32._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T41._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T31._Fld595 = ?)) T30
  1080. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000EA AND T1.Fld11293_RRRef = T30.IDRRef
  1081. LEFT OUTER JOIN dbo._Document263 T42
  1082. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x00000107 AND T1.Fld11293_RRRef = T42._IDRRef) AND (T42._Fld595 = ?)
  1083. LEFT OUTER JOIN (SELECT
  1084. T44._IDRRef AS IDRRef,
  1085. T44._Fld3845RRef AS Fld3845RRef,
  1086. T44._Fld595 AS Fld595_
  1087. FROM dbo._Document216 T44
  1088. WHERE ((EXISTS(SELECT
  1089. 1
  1090. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1091. LEFT OUTER JOIN dbo._Reference42 T45
  1092. ON ((T44._Fld3845RRef = T45._IDRRef)) AND (T45._Fld595 = ?)
  1093. WHERE EXISTS(SELECT
  1094. 0x01 AS Q_001_F_000_
  1095. FROM dbo._Reference98 T46
  1096. INNER JOIN dbo._Reference21 T47
  1097. ON (((T46._Fld1685 = ?) AND EXISTS(SELECT
  1098. 0x01 AS Q_004_F_000_
  1099. FROM dbo._InfoRg11709 T48
  1100. WHERE ((T48._Fld595 = ?)) AND ((T48._Fld12065RRef = T46._IDRRef) AND (T48._Fld12066RRef = T47._IDRRef)))) AND T47._IDRRef IN
  1101. (SELECT
  1102. T49._Reference21_IDRRef AS Q_005_F_000RRef
  1103. FROM dbo._Reference21_VT782 T49
  1104. INNER JOIN dbo._InfoRg9937 T50
  1105. ON ((T50._Fld9939_TYPE = 0x08 AND T50._Fld9939_RTRef = 0x00000095 AND T50._Fld9939_RRRef = ?) AND (T50._Fld9938_TYPE = T49._Fld784_TYPE AND T50._Fld9938_RTRef = T49._Fld784_RTRef AND T50._Fld9938_RRRef = T49._Fld784_RRRef))
  1106. WHERE ((T49._Fld595 = ?)) AND (T50._Fld595 = ?)))
  1107. WHERE ((T47._Fld595 = ?)) AND ((CASE WHEN T45._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1108. 0x01 AS Q_002_F_000_
  1109. FROM dbo._InfoRg11710 T51
  1110. WHERE ((T51._Fld595 = ?)) AND ((T51._Fld12072RRef = T47._IDRRef) AND (T51._Fld12073_TYPE = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x08 END AND T51._Fld12073_RTRef = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T51._Fld12073_RRRef = T45._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1111. 0x01 AS Q_003_F_000_
  1112. FROM dbo._InfoRg11715 T52
  1113. WHERE ((T52._Fld595 = ?)) AND ((T52._Fld12199RRef = T47._IDRRef) AND T52._Fld12200_TYPE = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x08 END AND T52._Fld12200_RTRef = CASE WHEN T45._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T52._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T44._Fld595 = ?)) T43
  1114. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D8 AND T1.Fld11293_RRRef = T43.IDRRef
  1115. LEFT OUTER JOIN (SELECT
  1116. T54._Fld595 AS Fld595_,
  1117. T54._IDRRef AS IDRRef,
  1118. T54._Fld3734RRef AS Fld3734RRef
  1119. FROM dbo._Document215 T54
  1120. WHERE ((EXISTS(SELECT
  1121. 1
  1122. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1123. LEFT OUTER JOIN dbo._Reference42 T55
  1124. ON ((T54._Fld3734RRef = T55._IDRRef)) AND (T55._Fld595 = ?)
  1125. WHERE EXISTS(SELECT
  1126. 0x01 AS Q_001_F_000_
  1127. FROM dbo._Reference98 T56
  1128. INNER JOIN dbo._Reference21 T57
  1129. ON (((T56._Fld1685 = ?) AND EXISTS(SELECT
  1130. 0x01 AS Q_004_F_000_
  1131. FROM dbo._InfoRg11709 T58
  1132. WHERE ((T58._Fld595 = ?)) AND ((T58._Fld12065RRef = T56._IDRRef) AND (T58._Fld12066RRef = T57._IDRRef)))) AND T57._IDRRef IN
  1133. (SELECT
  1134. T59._Reference21_IDRRef AS Q_005_F_000RRef
  1135. FROM dbo._Reference21_VT782 T59
  1136. INNER JOIN dbo._InfoRg9937 T60
  1137. ON ((T60._Fld9939_TYPE = 0x08 AND T60._Fld9939_RTRef = 0x00000095 AND T60._Fld9939_RRRef = ?) AND (T60._Fld9938_TYPE = T59._Fld784_TYPE AND T60._Fld9938_RTRef = T59._Fld784_RTRef AND T60._Fld9938_RRRef = T59._Fld784_RRRef))
  1138. WHERE ((T59._Fld595 = ?)) AND (T60._Fld595 = ?)))
  1139. WHERE ((T57._Fld595 = ?)) 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
  1140. 0x01 AS Q_002_F_000_
  1141. FROM dbo._InfoRg11710 T61
  1142. WHERE ((T61._Fld595 = ?)) 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
  1143. 0x01 AS Q_003_F_000_
  1144. FROM dbo._InfoRg11715 T62
  1145. WHERE ((T62._Fld595 = ?)) 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 = ?)) T53
  1146. ON T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D7 AND T1.Fld11293_RRRef = T53.IDRRef
  1147. LEFT OUTER JOIN dbo._Document213 T63
  1148. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D5 AND T1.Fld11293_RRRef = T63._IDRRef) AND (T63._Fld595 = ?)
  1149. LEFT OUTER JOIN dbo._Document199 T64
  1150. ON (T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000C7 AND T1.Fld11293_RRRef = T64._IDRRef) AND (T64._Fld595 = ?)
  1151. LEFT OUTER JOIN (SELECT
  1152. T66._IDRRef AS IDRRef,
  1153. T66._Fld12836RRef AS Fld12836RRef,
  1154. T66._Fld595 AS Fld595_,
  1155. T66._Folder AS Folder_
  1156. FROM dbo._Reference42 T66
  1157. WHERE ((((T66._Folder = 0x00) OR EXISTS(SELECT
  1158. 0x01 AS Q_001_F_000_
  1159. FROM dbo._Reference98 T67
  1160. INNER JOIN dbo._Reference21 T68
  1161. ON (((T67._Fld1685 = ?) AND EXISTS(SELECT
  1162. 0x01 AS Q_004_F_000_
  1163. FROM dbo._InfoRg11709 T69
  1164. WHERE ((T69._Fld595 = ?)) AND ((T69._Fld12065RRef = T67._IDRRef) AND (T69._Fld12066RRef = T68._IDRRef)))) AND T68._IDRRef IN
  1165. (SELECT
  1166. T70._Reference21_IDRRef AS Q_005_F_000RRef
  1167. FROM dbo._Reference21_VT782 T70
  1168. INNER JOIN dbo._InfoRg9937 T71
  1169. ON ((T71._Fld9939_TYPE = 0x08 AND T71._Fld9939_RTRef = 0x00000095 AND T71._Fld9939_RRRef = ?) AND (T71._Fld9938_TYPE = T70._Fld784_TYPE AND T71._Fld9938_RTRef = T70._Fld784_RTRef AND T71._Fld9938_RRRef = T70._Fld784_RRRef))
  1170. WHERE ((T70._Fld595 = ?)) AND (T71._Fld595 = ?)))
  1171. WHERE ((T68._Fld595 = ?)) 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
  1172. 0x01 AS Q_002_F_000_
  1173. FROM dbo._InfoRg11710 T72
  1174. WHERE ((T72._Fld595 = ?)) AND ((T72._Fld12072RRef = T68._IDRRef) AND (T72._Fld12073_TYPE = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x08 END AND T72._Fld12073_RTRef = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T72._Fld12073_RRRef = T66._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1175. 0x01 AS Q_003_F_000_
  1176. FROM dbo._InfoRg11715 T73
  1177. WHERE ((T73._Fld595 = ?)) AND ((T73._Fld12199RRef = T68._IDRRef) AND T73._Fld12200_TYPE = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x08 END AND T73._Fld12200_RTRef = CASE WHEN T66._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T73._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T66._Fld595 = ?)) T65
  1178. ON (CASE WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000E9 THEN T19.Fld4625RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D4 THEN T29._Fld3516RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000EA THEN T30.Fld4774RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x00000107 THEN T42._Fld6287RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D8 THEN T43.Fld3845RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D7 THEN T53.Fld3734RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000D5 THEN T63._Fld3600RRef WHEN T1.Fld11293_TYPE = 0x08 AND T1.Fld11293_RTRef = 0x000000C7 THEN T64._Fld2840RRef ELSE CAST(NULL AS BINARY(16)) END = T65.IDRRef)
  1179. UNION ALL SELECT
  1180. T74.Fld10332_TYPE,
  1181. T74.Fld10332_RTRef,
  1182. T74.Fld10332_RRRef,
  1183. T74.Fld10328RRef,
  1184. CAST(NULL AS NUMERIC(28, 2)),
  1185. T74.Fld10330RRef,
  1186. T74.Fld10334Expense_,
  1187. T84.Fld12836RRef
  1188. FROM (SELECT
  1189. T75._RecorderTRef AS RecorderTRef,
  1190. T75._RecorderRRef AS RecorderRRef,
  1191. T75._Fld10332_TYPE AS Fld10332_TYPE,
  1192. T75._Fld10332_RTRef AS Fld10332_RTRef,
  1193. T75._Fld10332_RRRef AS Fld10332_RRRef,
  1194. T75._Fld10328RRef AS Fld10328RRef,
  1195. T75._Fld10330RRef AS Fld10330RRef,
  1196. CAST(SUM(CASE WHEN T75._RecordKind = 0.0 THEN 0.0 ELSE T75._Fld10334 END) AS NUMERIC(27, 8)) AS Fld10334Expense_
  1197. FROM dbo._AccumRg10327 T75
  1198. WHERE (((T75._Fld595 = ?)) AND (EXISTS(SELECT
  1199. 1
  1200. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1201. LEFT OUTER JOIN dbo._Reference42 T76
  1202. ON ((T75._Fld10330RRef = T76._IDRRef)) AND (T76._Fld595 = ?)
  1203. WHERE EXISTS(SELECT
  1204. 0x01 AS Q_001_F_000_
  1205. FROM dbo._Reference98 T77
  1206. INNER JOIN dbo._Reference21 T78
  1207. ON (((T77._Fld1685 = ?) AND EXISTS(SELECT
  1208. 0x01 AS Q_004_F_000_
  1209. FROM dbo._InfoRg11709 T79
  1210. WHERE ((T79._Fld595 = ?)) AND ((T79._Fld12065RRef = T77._IDRRef) AND (T79._Fld12066RRef = T78._IDRRef)))) AND T78._IDRRef IN
  1211. (SELECT
  1212. T80._Reference21_IDRRef AS Q_005_F_000RRef
  1213. FROM dbo._Reference21_VT782 T80
  1214. INNER JOIN dbo._InfoRg9937 T81
  1215. ON ((T81._Fld9939_TYPE = 0x08 AND T81._Fld9939_RTRef = 0x00000095 AND T81._Fld9939_RRRef = ?) AND (T81._Fld9938_TYPE = T80._Fld784_TYPE AND T81._Fld9938_RTRef = T80._Fld784_RTRef AND T81._Fld9938_RRRef = T80._Fld784_RRRef))
  1216. WHERE ((T80._Fld595 = ?)) AND (T81._Fld595 = ?)))
  1217. WHERE ((T78._Fld595 = ?)) AND ((CASE WHEN T76._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T76._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1218. 0x01 AS Q_002_F_000_
  1219. FROM dbo._InfoRg11710 T82
  1220. WHERE ((T82._Fld595 = ?)) AND ((T82._Fld12072RRef = T78._IDRRef) AND (T82._Fld12073_TYPE = CASE WHEN T76._Fld12836RRef IS NOT NULL THEN 0x08 END AND T82._Fld12073_RTRef = CASE WHEN T76._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T82._Fld12073_RRRef = T76._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1221. 0x01 AS Q_003_F_000_
  1222. FROM dbo._InfoRg11715 T83
  1223. WHERE ((T83._Fld595 = ?)) AND ((T83._Fld12199RRef = T78._IDRRef) AND T83._Fld12200_TYPE = CASE WHEN T76._Fld12836RRef IS NOT NULL THEN 0x08 END AND T83._Fld12200_RTRef = CASE WHEN T76._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T83._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T75._Period >= ? AND T75._Period <= ? AND T75._Active = 0x01 AND T75._RecordKind = ?)
  1224. GROUP BY T75._RecorderTRef,
  1225. T75._RecorderRRef,
  1226. T75._Fld10332_TYPE,
  1227. T75._Fld10332_RTRef,
  1228. T75._Fld10332_RRRef,
  1229. T75._Fld10328RRef,
  1230. T75._Fld10330RRef
  1231. HAVING (CAST(SUM(CASE WHEN T75._RecordKind = 0.0 THEN 0.0 ELSE T75._Fld10334 END) AS NUMERIC(27, 8))) <> 0.0) T74
  1232. LEFT OUTER JOIN (SELECT
  1233. T85._IDRRef AS IDRRef,
  1234. T85._Fld12836RRef AS Fld12836RRef,
  1235. T85._Fld595 AS Fld595_,
  1236. T85._Folder AS Folder_
  1237. FROM dbo._Reference42 T85
  1238. WHERE ((((T85._Folder = 0x00) OR EXISTS(SELECT
  1239. 0x01 AS Q_001_F_000_
  1240. FROM dbo._Reference98 T86
  1241. INNER JOIN dbo._Reference21 T87
  1242. ON (((T86._Fld1685 = ?) AND EXISTS(SELECT
  1243. 0x01 AS Q_004_F_000_
  1244. FROM dbo._InfoRg11709 T88
  1245. WHERE ((T88._Fld595 = ?)) AND ((T88._Fld12065RRef = T86._IDRRef) AND (T88._Fld12066RRef = T87._IDRRef)))) AND T87._IDRRef IN
  1246. (SELECT
  1247. T89._Reference21_IDRRef AS Q_005_F_000RRef
  1248. FROM dbo._Reference21_VT782 T89
  1249. INNER JOIN dbo._InfoRg9937 T90
  1250. ON ((T90._Fld9939_TYPE = 0x08 AND T90._Fld9939_RTRef = 0x00000095 AND T90._Fld9939_RRRef = ?) AND (T90._Fld9938_TYPE = T89._Fld784_TYPE AND T90._Fld9938_RTRef = T89._Fld784_RTRef AND T90._Fld9938_RRRef = T89._Fld784_RRRef))
  1251. WHERE ((T89._Fld595 = ?)) AND (T90._Fld595 = ?)))
  1252. WHERE ((T87._Fld595 = ?)) AND ((CASE WHEN T85._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T85._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1253. 0x01 AS Q_002_F_000_
  1254. FROM dbo._InfoRg11710 T91
  1255. WHERE ((T91._Fld595 = ?)) AND ((T91._Fld12072RRef = T87._IDRRef) AND (T91._Fld12073_TYPE = CASE WHEN T85._Fld12836RRef IS NOT NULL THEN 0x08 END AND T91._Fld12073_RTRef = CASE WHEN T85._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T91._Fld12073_RRRef = T85._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1256. 0x01 AS Q_003_F_000_
  1257. FROM dbo._InfoRg11715 T92
  1258. WHERE ((T92._Fld595 = ?)) AND ((T92._Fld12199RRef = T87._IDRRef) AND T92._Fld12200_TYPE = CASE WHEN T85._Fld12836RRef IS NOT NULL THEN 0x08 END AND T92._Fld12200_RTRef = CASE WHEN T85._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T92._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T85._Fld595 = ?)) T84
  1259. ON T74.Fld10330RRef = T84.IDRRef
  1260. WHERE (T74.RecorderTRef = 0x000000D3)
  1261. UNION ALL SELECT
  1262. T93.Fld10540_TYPE,
  1263. T93.Fld10540_RTRef,
  1264. T93.Fld10540_RRRef,
  1265. T93.Fld10536RRef,
  1266. CAST(NULL AS NUMERIC(28, 2)),
  1267. T93.Fld10538RRef,
  1268. T93.Fld10544Expense_,
  1269. T103.Fld12836RRef
  1270. FROM (SELECT
  1271. T94._RecorderTRef AS RecorderTRef,
  1272. T94._RecorderRRef AS RecorderRRef,
  1273. T94._Fld10540_TYPE AS Fld10540_TYPE,
  1274. T94._Fld10540_RTRef AS Fld10540_RTRef,
  1275. T94._Fld10540_RRRef AS Fld10540_RRRef,
  1276. T94._Fld10538RRef AS Fld10538RRef,
  1277. T94._Fld10536RRef AS Fld10536RRef,
  1278. CAST(SUM(CASE WHEN T94._RecordKind = 0.0 THEN 0.0 ELSE T94._Fld10544 END) AS NUMERIC(27, 8)) AS Fld10544Expense_
  1279. FROM dbo._AccumRg10535 T94
  1280. WHERE (((T94._Fld595 = ?)) AND (EXISTS(SELECT
  1281. 1
  1282. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1283. LEFT OUTER JOIN dbo._Reference42 T95
  1284. ON ((T94._Fld10538RRef = T95._IDRRef)) AND (T95._Fld595 = ?)
  1285. WHERE EXISTS(SELECT
  1286. 0x01 AS Q_001_F_000_
  1287. FROM dbo._Reference98 T96
  1288. INNER JOIN dbo._Reference21 T97
  1289. ON (((T96._Fld1685 = ?) AND EXISTS(SELECT
  1290. 0x01 AS Q_004_F_000_
  1291. FROM dbo._InfoRg11709 T98
  1292. WHERE ((T98._Fld595 = ?)) AND ((T98._Fld12065RRef = T96._IDRRef) AND (T98._Fld12066RRef = T97._IDRRef)))) AND T97._IDRRef IN
  1293. (SELECT
  1294. T99._Reference21_IDRRef AS Q_005_F_000RRef
  1295. FROM dbo._Reference21_VT782 T99
  1296. INNER JOIN dbo._InfoRg9937 T100
  1297. ON ((T100._Fld9939_TYPE = 0x08 AND T100._Fld9939_RTRef = 0x00000095 AND T100._Fld9939_RRRef = ?) AND (T100._Fld9938_TYPE = T99._Fld784_TYPE AND T100._Fld9938_RTRef = T99._Fld784_RTRef AND T100._Fld9938_RRRef = T99._Fld784_RRRef))
  1298. WHERE ((T99._Fld595 = ?)) AND (T100._Fld595 = ?)))
  1299. WHERE ((T97._Fld595 = ?)) AND ((CASE WHEN T95._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T95._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1300. 0x01 AS Q_002_F_000_
  1301. FROM dbo._InfoRg11710 T101
  1302. WHERE ((T101._Fld595 = ?)) AND ((T101._Fld12072RRef = T97._IDRRef) AND (T101._Fld12073_TYPE = CASE WHEN T95._Fld12836RRef IS NOT NULL THEN 0x08 END AND T101._Fld12073_RTRef = CASE WHEN T95._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T101._Fld12073_RRRef = T95._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1303. 0x01 AS Q_003_F_000_
  1304. FROM dbo._InfoRg11715 T102
  1305. WHERE ((T102._Fld595 = ?)) AND ((T102._Fld12199RRef = T97._IDRRef) AND T102._Fld12200_TYPE = CASE WHEN T95._Fld12836RRef IS NOT NULL THEN 0x08 END AND T102._Fld12200_RTRef = CASE WHEN T95._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T102._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T94._Period >= ? AND T94._Period <= ? AND T94._Active = 0x01 AND T94._RecordKind = ?)
  1306. GROUP BY T94._RecorderTRef,
  1307. T94._RecorderRRef,
  1308. T94._Fld10540_TYPE,
  1309. T94._Fld10540_RTRef,
  1310. T94._Fld10540_RRRef,
  1311. T94._Fld10538RRef,
  1312. T94._Fld10536RRef
  1313. HAVING (CAST(SUM(CASE WHEN T94._RecordKind = 0.0 THEN 0.0 ELSE T94._Fld10544 END) AS NUMERIC(27, 8))) <> 0.0) T93
  1314. LEFT OUTER JOIN (SELECT
  1315. T104._IDRRef AS IDRRef,
  1316. T104._Fld12836RRef AS Fld12836RRef,
  1317. T104._Fld595 AS Fld595_,
  1318. T104._Folder AS Folder_
  1319. FROM dbo._Reference42 T104
  1320. WHERE ((((T104._Folder = 0x00) OR EXISTS(SELECT
  1321. 0x01 AS Q_001_F_000_
  1322. FROM dbo._Reference98 T105
  1323. INNER JOIN dbo._Reference21 T106
  1324. ON (((T105._Fld1685 = ?) AND EXISTS(SELECT
  1325. 0x01 AS Q_004_F_000_
  1326. FROM dbo._InfoRg11709 T107
  1327. WHERE ((T107._Fld595 = ?)) AND ((T107._Fld12065RRef = T105._IDRRef) AND (T107._Fld12066RRef = T106._IDRRef)))) AND T106._IDRRef IN
  1328. (SELECT
  1329. T108._Reference21_IDRRef AS Q_005_F_000RRef
  1330. FROM dbo._Reference21_VT782 T108
  1331. INNER JOIN dbo._InfoRg9937 T109
  1332. ON ((T109._Fld9939_TYPE = 0x08 AND T109._Fld9939_RTRef = 0x00000095 AND T109._Fld9939_RRRef = ?) AND (T109._Fld9938_TYPE = T108._Fld784_TYPE AND T109._Fld9938_RTRef = T108._Fld784_RTRef AND T109._Fld9938_RRRef = T108._Fld784_RRRef))
  1333. WHERE ((T108._Fld595 = ?)) AND (T109._Fld595 = ?)))
  1334. WHERE ((T106._Fld595 = ?)) AND ((CASE WHEN T104._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T104._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1335. 0x01 AS Q_002_F_000_
  1336. FROM dbo._InfoRg11710 T110
  1337. WHERE ((T110._Fld595 = ?)) AND ((T110._Fld12072RRef = T106._IDRRef) AND (T110._Fld12073_TYPE = CASE WHEN T104._Fld12836RRef IS NOT NULL THEN 0x08 END AND T110._Fld12073_RTRef = CASE WHEN T104._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T110._Fld12073_RRRef = T104._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1338. 0x01 AS Q_003_F_000_
  1339. FROM dbo._InfoRg11715 T111
  1340. WHERE ((T111._Fld595 = ?)) AND ((T111._Fld12199RRef = T106._IDRRef) AND T111._Fld12200_TYPE = CASE WHEN T104._Fld12836RRef IS NOT NULL THEN 0x08 END AND T111._Fld12200_RTRef = CASE WHEN T104._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T111._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T104._Fld595 = ?)) T103
  1341. ON T93.Fld10538RRef = T103.IDRRef
  1342. LEFT OUTER JOIN (SELECT
  1343. T113._IDRRef AS IDRRef,
  1344. T113._Fld4634_TYPE AS Fld4634_TYPE,
  1345. T113._Fld4634_RTRef AS Fld4634_RTRef,
  1346. T113._Fld4634_RRRef AS Fld4634_RRRef,
  1347. T113._Fld4625RRef AS Fld4625RRef,
  1348. T113._Fld595 AS Fld595_
  1349. FROM dbo._Document233 T113
  1350. WHERE ((EXISTS(SELECT
  1351. 1
  1352. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1353. LEFT OUTER JOIN dbo._Reference42 T114
  1354. ON ((T113._Fld4625RRef = T114._IDRRef)) AND (T114._Fld595 = ?)
  1355. WHERE EXISTS(SELECT
  1356. 0x01 AS Q_001_F_000_
  1357. FROM dbo._Reference98 T115
  1358. INNER JOIN dbo._Reference21 T116
  1359. ON (((T115._Fld1685 = ?) AND EXISTS(SELECT
  1360. 0x01 AS Q_004_F_000_
  1361. FROM dbo._InfoRg11709 T117
  1362. WHERE ((T117._Fld595 = ?)) AND ((T117._Fld12065RRef = T115._IDRRef) AND (T117._Fld12066RRef = T116._IDRRef)))) AND T116._IDRRef IN
  1363. (SELECT
  1364. T118._Reference21_IDRRef AS Q_005_F_000RRef
  1365. FROM dbo._Reference21_VT782 T118
  1366. INNER JOIN dbo._InfoRg9937 T119
  1367. ON ((T119._Fld9939_TYPE = 0x08 AND T119._Fld9939_RTRef = 0x00000095 AND T119._Fld9939_RRRef = ?) AND (T119._Fld9938_TYPE = T118._Fld784_TYPE AND T119._Fld9938_RTRef = T118._Fld784_RTRef AND T119._Fld9938_RRRef = T118._Fld784_RRRef))
  1368. WHERE ((T118._Fld595 = ?)) AND (T119._Fld595 = ?)))
  1369. WHERE ((T116._Fld595 = ?)) AND ((CASE WHEN T114._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T114._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1370. 0x01 AS Q_002_F_000_
  1371. FROM dbo._InfoRg11710 T120
  1372. WHERE ((T120._Fld595 = ?)) AND ((T120._Fld12072RRef = T116._IDRRef) AND (T120._Fld12073_TYPE = CASE WHEN T114._Fld12836RRef IS NOT NULL THEN 0x08 END AND T120._Fld12073_RTRef = CASE WHEN T114._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T120._Fld12073_RRRef = T114._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1373. 0x01 AS Q_003_F_000_
  1374. FROM dbo._InfoRg11715 T121
  1375. WHERE ((T121._Fld595 = ?)) AND ((T121._Fld12199RRef = T116._IDRRef) AND T121._Fld12200_TYPE = CASE WHEN T114._Fld12836RRef IS NOT NULL THEN 0x08 END AND T121._Fld12200_RTRef = CASE WHEN T114._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T121._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T113._Fld595 = ?)) T112
  1376. ON T93.RecorderTRef = 0x000000E9 AND T93.RecorderRRef = T112.IDRRef
  1377. LEFT OUTER JOIN dbo._Document212 T122
  1378. ON (T93.RecorderTRef = 0x000000D4 AND T93.RecorderRRef = T122._IDRRef) AND (T122._Fld595 = ?)
  1379. LEFT OUTER JOIN (SELECT
  1380. T124._IDRRef AS IDRRef,
  1381. T124._Fld4779RRef AS Fld4779RRef,
  1382. T124._Fld595 AS Fld595_,
  1383. T124._Fld4782_TYPE AS Fld4782_TYPE,
  1384. T124._Fld4782_RTRef AS Fld4782_RTRef,
  1385. T124._Fld4782_RRRef AS Fld4782_RRRef,
  1386. T124._Fld4774RRef AS Fld4774RRef
  1387. FROM dbo._Document234 T124
  1388. WHERE ((EXISTS(SELECT
  1389. 1
  1390. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1391. LEFT OUTER JOIN dbo._Reference42 T125
  1392. ON ((T124._Fld4774RRef = T125._IDRRef)) AND (T125._Fld595 = ?)
  1393. WHERE EXISTS(SELECT
  1394. 0x01 AS Q_001_F_000_
  1395. FROM dbo._Reference98 T126
  1396. INNER JOIN dbo._Reference21 T127
  1397. ON (((T126._Fld1685 = ?) AND EXISTS(SELECT
  1398. 0x01 AS Q_006_F_000_
  1399. FROM dbo._InfoRg11709 T128
  1400. WHERE ((T128._Fld595 = ?)) AND ((T128._Fld12065RRef = T126._IDRRef) AND (T128._Fld12066RRef = T127._IDRRef)))) AND T127._IDRRef IN
  1401. (SELECT
  1402. T129._Reference21_IDRRef AS Q_007_F_000RRef
  1403. FROM dbo._Reference21_VT782 T129
  1404. INNER JOIN dbo._InfoRg9937 T130
  1405. ON ((T130._Fld9939_TYPE = 0x08 AND T130._Fld9939_RTRef = 0x00000095 AND T130._Fld9939_RRRef = ?) AND (T130._Fld9938_TYPE = T129._Fld784_TYPE AND T130._Fld9938_RTRef = T129._Fld784_RTRef AND T130._Fld9938_RRRef = T129._Fld784_RRRef))
  1406. WHERE ((T129._Fld595 = ?)) AND (T130._Fld595 = ?)))
  1407. WHERE ((T127._Fld595 = ?)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1408. 0x01 AS Q_002_F_000_
  1409. FROM dbo._InfoRg11710 T131
  1410. WHERE ((T131._Fld595 = ?)) AND ((T131._Fld12072RRef = T127._IDRRef) AND (T131._Fld12073_TYPE = 0x08 AND T131._Fld12073_RTRef = 0x0000001C AND T131._Fld12073_RRRef = T124._Fld4779RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1411. 0x01 AS Q_003_F_000_
  1412. FROM dbo._InfoRg11715 T132
  1413. WHERE ((T132._Fld595 = ?)) AND ((T132._Fld12199RRef = T127._IDRRef) AND T132._Fld12200_TYPE = 0x08 AND T132._Fld12200_RTRef = 0x0000001C AND (T132._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END) AND (CASE WHEN T125._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T125._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1414. 0x01 AS Q_004_F_000_
  1415. FROM dbo._InfoRg11710 T133
  1416. WHERE ((T133._Fld595 = ?)) AND ((T133._Fld12072RRef = T127._IDRRef) AND (T133._Fld12073_TYPE = CASE WHEN T125._Fld12836RRef IS NOT NULL THEN 0x08 END AND T133._Fld12073_RTRef = CASE WHEN T125._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T133._Fld12073_RRRef = T125._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1417. 0x01 AS Q_005_F_000_
  1418. FROM dbo._InfoRg11715 T134
  1419. WHERE ((T134._Fld595 = ?)) AND ((T134._Fld12199RRef = T127._IDRRef) AND T134._Fld12200_TYPE = CASE WHEN T125._Fld12836RRef IS NOT NULL THEN 0x08 END AND T134._Fld12200_RTRef = CASE WHEN T125._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T134._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T124._Fld595 = ?)) T123
  1420. ON T93.RecorderTRef = 0x000000EA AND T93.RecorderRRef = T123.IDRRef
  1421. LEFT OUTER JOIN dbo._Document253 T135
  1422. ON (T93.RecorderTRef = 0x000000FD AND T93.RecorderRRef = T135._IDRRef) AND (T135._Fld595 = ?)
  1423. LEFT OUTER JOIN (SELECT
  1424. T137._IDRRef AS IDRRef,
  1425. T137._Fld595 AS Fld595_,
  1426. T137._Fld6145_TYPE AS Fld6145_TYPE,
  1427. T137._Fld6145_RTRef AS Fld6145_RTRef,
  1428. T137._Fld6145_RRRef AS Fld6145_RRRef,
  1429. T137._Fld6139RRef AS Fld6139RRef
  1430. FROM dbo._Document259 T137
  1431. WHERE ((EXISTS(SELECT
  1432. 1
  1433. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1434. LEFT OUTER JOIN dbo._Reference42 T138
  1435. ON ((T137._Fld6139RRef = T138._IDRRef)) AND (T138._Fld595 = ?)
  1436. WHERE EXISTS(SELECT
  1437. 0x01 AS Q_001_F_000_
  1438. FROM dbo._Reference98 T139
  1439. INNER JOIN dbo._Reference21 T140
  1440. ON (((T139._Fld1685 = ?) AND EXISTS(SELECT
  1441. 0x01 AS Q_004_F_000_
  1442. FROM dbo._InfoRg11709 T141
  1443. WHERE ((T141._Fld595 = ?)) AND ((T141._Fld12065RRef = T139._IDRRef) AND (T141._Fld12066RRef = T140._IDRRef)))) AND T140._IDRRef IN
  1444. (SELECT
  1445. T142._Reference21_IDRRef AS Q_005_F_000RRef
  1446. FROM dbo._Reference21_VT782 T142
  1447. INNER JOIN dbo._InfoRg9937 T143
  1448. ON ((T143._Fld9939_TYPE = 0x08 AND T143._Fld9939_RTRef = 0x00000095 AND T143._Fld9939_RRRef = ?) AND (T143._Fld9938_TYPE = T142._Fld784_TYPE AND T143._Fld9938_RTRef = T142._Fld784_RTRef AND T143._Fld9938_RRRef = T142._Fld784_RRRef))
  1449. WHERE ((T142._Fld595 = ?)) AND (T143._Fld595 = ?)))
  1450. WHERE ((T140._Fld595 = ?)) AND ((CASE WHEN T138._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T138._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1451. 0x01 AS Q_002_F_000_
  1452. FROM dbo._InfoRg11710 T144
  1453. WHERE ((T144._Fld595 = ?)) AND ((T144._Fld12072RRef = T140._IDRRef) AND (T144._Fld12073_TYPE = CASE WHEN T138._Fld12836RRef IS NOT NULL THEN 0x08 END AND T144._Fld12073_RTRef = CASE WHEN T138._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T144._Fld12073_RRRef = T138._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1454. 0x01 AS Q_003_F_000_
  1455. FROM dbo._InfoRg11715 T145
  1456. WHERE ((T145._Fld595 = ?)) AND ((T145._Fld12199RRef = T140._IDRRef) AND T145._Fld12200_TYPE = CASE WHEN T138._Fld12836RRef IS NOT NULL THEN 0x08 END AND T145._Fld12200_RTRef = CASE WHEN T138._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T145._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T137._Fld595 = ?)) T136
  1457. ON T93.RecorderTRef = 0x00000103 AND T93.RecorderRRef = T136.IDRRef
  1458. LEFT OUTER JOIN (SELECT
  1459. T147._IDRRef AS IDRRef,
  1460. T147._Fld3845RRef AS Fld3845RRef,
  1461. T147._Fld3852_TYPE AS Fld3852_TYPE,
  1462. T147._Fld3852_RTRef AS Fld3852_RTRef,
  1463. T147._Fld3852_RRRef AS Fld3852_RRRef,
  1464. T147._Fld595 AS Fld595_
  1465. FROM dbo._Document216 T147
  1466. WHERE ((EXISTS(SELECT
  1467. 1
  1468. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1469. LEFT OUTER JOIN dbo._Reference42 T148
  1470. ON ((T147._Fld3845RRef = T148._IDRRef)) AND (T148._Fld595 = ?)
  1471. WHERE EXISTS(SELECT
  1472. 0x01 AS Q_001_F_000_
  1473. FROM dbo._Reference98 T149
  1474. INNER JOIN dbo._Reference21 T150
  1475. ON (((T149._Fld1685 = ?) AND EXISTS(SELECT
  1476. 0x01 AS Q_004_F_000_
  1477. FROM dbo._InfoRg11709 T151
  1478. WHERE ((T151._Fld595 = ?)) AND ((T151._Fld12065RRef = T149._IDRRef) AND (T151._Fld12066RRef = T150._IDRRef)))) AND T150._IDRRef IN
  1479. (SELECT
  1480. T152._Reference21_IDRRef AS Q_005_F_000RRef
  1481. FROM dbo._Reference21_VT782 T152
  1482. INNER JOIN dbo._InfoRg9937 T153
  1483. ON ((T153._Fld9939_TYPE = 0x08 AND T153._Fld9939_RTRef = 0x00000095 AND T153._Fld9939_RRRef = ?) AND (T153._Fld9938_TYPE = T152._Fld784_TYPE AND T153._Fld9938_RTRef = T152._Fld784_RTRef AND T153._Fld9938_RRRef = T152._Fld784_RRRef))
  1484. WHERE ((T152._Fld595 = ?)) AND (T153._Fld595 = ?)))
  1485. WHERE ((T150._Fld595 = ?)) AND ((CASE WHEN T148._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T148._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1486. 0x01 AS Q_002_F_000_
  1487. FROM dbo._InfoRg11710 T154
  1488. WHERE ((T154._Fld595 = ?)) AND ((T154._Fld12072RRef = T150._IDRRef) AND (T154._Fld12073_TYPE = CASE WHEN T148._Fld12836RRef IS NOT NULL THEN 0x08 END AND T154._Fld12073_RTRef = CASE WHEN T148._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T154._Fld12073_RRRef = T148._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1489. 0x01 AS Q_003_F_000_
  1490. FROM dbo._InfoRg11715 T155
  1491. WHERE ((T155._Fld595 = ?)) AND ((T155._Fld12199RRef = T150._IDRRef) AND T155._Fld12200_TYPE = CASE WHEN T148._Fld12836RRef IS NOT NULL THEN 0x08 END AND T155._Fld12200_RTRef = CASE WHEN T148._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T155._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T147._Fld595 = ?)) T146
  1492. ON T93.RecorderTRef = 0x000000D8 AND T93.RecorderRRef = T146.IDRRef
  1493. LEFT OUTER JOIN (SELECT
  1494. T157._IDRRef AS IDRRef,
  1495. T157._Fld3325_TYPE AS Fld3325_TYPE,
  1496. T157._Fld3325_RTRef AS Fld3325_RTRef,
  1497. T157._Fld3325_RRRef AS Fld3325_RRRef,
  1498. T157._Fld595 AS Fld595_
  1499. FROM dbo._Document209 T157
  1500. WHERE ((EXISTS(SELECT
  1501. 1
  1502. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1503. LEFT OUTER JOIN dbo._Document211 T158
  1504. ON (T157._Fld3325_TYPE = 0x08 AND T157._Fld3325_RTRef = 0x000000D3 AND T157._Fld3325_RRRef = T158._IDRRef) AND (T158._Fld595 = ?)
  1505. LEFT OUTER JOIN dbo._Document210 T159
  1506. ON (T157._Fld3325_TYPE = 0x08 AND T157._Fld3325_RTRef = 0x000000D2 AND T157._Fld3325_RRRef = T159._IDRRef) AND (T159._Fld595 = ?)
  1507. LEFT OUTER JOIN dbo._Reference42 T160
  1508. ON ((CASE WHEN T157._Fld3325_TYPE = 0x08 AND T157._Fld3325_RTRef = 0x000000D3 THEN T158._Fld3438RRef WHEN T157._Fld3325_TYPE = 0x08 AND T157._Fld3325_RTRef = 0x000000D2 THEN T159._Fld3343RRef ELSE CAST(NULL AS BINARY(16)) END = T160._IDRRef)) AND (T160._Fld595 = ?)
  1509. WHERE EXISTS(SELECT
  1510. 0x01 AS Q_001_F_000_
  1511. FROM dbo._Reference98 T161
  1512. INNER JOIN dbo._Reference21 T162
  1513. ON (((T161._Fld1685 = ?) AND EXISTS(SELECT
  1514. 0x01 AS Q_004_F_000_
  1515. FROM dbo._InfoRg11709 T163
  1516. WHERE ((T163._Fld595 = ?)) AND ((T163._Fld12065RRef = T161._IDRRef) AND (T163._Fld12066RRef = T162._IDRRef)))) AND T162._IDRRef IN
  1517. (SELECT
  1518. T164._Reference21_IDRRef AS Q_005_F_000RRef
  1519. FROM dbo._Reference21_VT782 T164
  1520. INNER JOIN dbo._InfoRg9937 T165
  1521. ON ((T165._Fld9939_TYPE = 0x08 AND T165._Fld9939_RTRef = 0x00000095 AND T165._Fld9939_RRRef = ?) AND (T165._Fld9938_TYPE = T164._Fld784_TYPE AND T165._Fld9938_RTRef = T164._Fld784_RTRef AND T165._Fld9938_RRRef = T164._Fld784_RRRef))
  1522. WHERE ((T164._Fld595 = ?)) AND (T165._Fld595 = ?)))
  1523. WHERE ((T162._Fld595 = ?)) AND ((CASE WHEN T160._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T160._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1524. 0x01 AS Q_002_F_000_
  1525. FROM dbo._InfoRg11710 T166
  1526. WHERE ((T166._Fld595 = ?)) AND ((T166._Fld12072RRef = T162._IDRRef) AND (T166._Fld12073_TYPE = CASE WHEN T160._Fld12836RRef IS NOT NULL THEN 0x08 END AND T166._Fld12073_RTRef = CASE WHEN T160._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T166._Fld12073_RRRef = T160._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1527. 0x01 AS Q_003_F_000_
  1528. FROM dbo._InfoRg11715 T167
  1529. WHERE ((T167._Fld595 = ?)) AND ((T167._Fld12199RRef = T162._IDRRef) AND T167._Fld12200_TYPE = CASE WHEN T160._Fld12836RRef IS NOT NULL THEN 0x08 END AND T167._Fld12200_RTRef = CASE WHEN T160._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T167._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T157._Fld595 = ?)) T156
  1530. ON T93.RecorderTRef = 0x000000D1 AND T93.RecorderRRef = T156.IDRRef
  1531. LEFT OUTER JOIN (SELECT
  1532. T169._Fld595 AS Fld595_,
  1533. T169._IDRRef AS IDRRef,
  1534. T169._Fld3734RRef AS Fld3734RRef,
  1535. T169._Fld3739RRef AS Fld3739RRef
  1536. FROM dbo._Document215 T169
  1537. WHERE ((EXISTS(SELECT
  1538. 1
  1539. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1540. LEFT OUTER JOIN dbo._Reference42 T170
  1541. ON ((T169._Fld3734RRef = T170._IDRRef)) AND (T170._Fld595 = ?)
  1542. WHERE EXISTS(SELECT
  1543. 0x01 AS Q_001_F_000_
  1544. FROM dbo._Reference98 T171
  1545. INNER JOIN dbo._Reference21 T172
  1546. ON (((T171._Fld1685 = ?) AND EXISTS(SELECT
  1547. 0x01 AS Q_004_F_000_
  1548. FROM dbo._InfoRg11709 T173
  1549. WHERE ((T173._Fld595 = ?)) AND ((T173._Fld12065RRef = T171._IDRRef) AND (T173._Fld12066RRef = T172._IDRRef)))) AND T172._IDRRef IN
  1550. (SELECT
  1551. T174._Reference21_IDRRef AS Q_005_F_000RRef
  1552. FROM dbo._Reference21_VT782 T174
  1553. INNER JOIN dbo._InfoRg9937 T175
  1554. ON ((T175._Fld9939_TYPE = 0x08 AND T175._Fld9939_RTRef = 0x00000095 AND T175._Fld9939_RRRef = ?) AND (T175._Fld9938_TYPE = T174._Fld784_TYPE AND T175._Fld9938_RTRef = T174._Fld784_RTRef AND T175._Fld9938_RRRef = T174._Fld784_RRRef))
  1555. WHERE ((T174._Fld595 = ?)) AND (T175._Fld595 = ?)))
  1556. WHERE ((T172._Fld595 = ?)) AND ((CASE WHEN T170._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T170._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1557. 0x01 AS Q_002_F_000_
  1558. FROM dbo._InfoRg11710 T176
  1559. WHERE ((T176._Fld595 = ?)) AND ((T176._Fld12072RRef = T172._IDRRef) AND (T176._Fld12073_TYPE = CASE WHEN T170._Fld12836RRef IS NOT NULL THEN 0x08 END AND T176._Fld12073_RTRef = CASE WHEN T170._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T176._Fld12073_RRRef = T170._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1560. 0x01 AS Q_003_F_000_
  1561. FROM dbo._InfoRg11715 T177
  1562. WHERE ((T177._Fld595 = ?)) AND ((T177._Fld12199RRef = T172._IDRRef) AND T177._Fld12200_TYPE = CASE WHEN T170._Fld12836RRef IS NOT NULL THEN 0x08 END AND T177._Fld12200_RTRef = CASE WHEN T170._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T177._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T169._Fld595 = ?)) T168
  1563. ON T93.RecorderTRef = 0x000000D7 AND T93.RecorderRRef = T168.IDRRef
  1564. LEFT OUTER JOIN (SELECT
  1565. T179._Fld6057_TYPE AS Fld6057_TYPE,
  1566. T179._Fld6057_RTRef AS Fld6057_RTRef,
  1567. T179._Fld6057_RRRef AS Fld6057_RRRef,
  1568. T179._IDRRef AS IDRRef,
  1569. T179._Fld6064RRef AS Fld6064RRef,
  1570. T179._Fld595 AS Fld595_
  1571. FROM dbo._Document258 T179
  1572. WHERE ((EXISTS(SELECT
  1573. 0x01 AS Q_001_F_000_
  1574. FROM dbo._Reference98 T180
  1575. INNER JOIN dbo._Reference21 T181
  1576. ON (((T180._Fld1685 = ?) AND EXISTS(SELECT
  1577. 0x01 AS Q_004_F_000_
  1578. FROM dbo._InfoRg11709 T182
  1579. WHERE ((T182._Fld595 = ?)) AND ((T182._Fld12065RRef = T180._IDRRef) AND (T182._Fld12066RRef = T181._IDRRef)))) AND T181._IDRRef IN
  1580. (SELECT
  1581. T183._Reference21_IDRRef AS Q_005_F_000RRef
  1582. FROM dbo._Reference21_VT782 T183
  1583. INNER JOIN dbo._InfoRg9937 T184
  1584. ON ((T184._Fld9939_TYPE = 0x08 AND T184._Fld9939_RTRef = 0x00000095 AND T184._Fld9939_RRRef = ?) AND (T184._Fld9938_TYPE = T183._Fld784_TYPE AND T184._Fld9938_RTRef = T183._Fld784_RTRef AND T184._Fld9938_RRRef = T183._Fld784_RRRef))
  1585. WHERE ((T183._Fld595 = ?)) AND (T184._Fld595 = ?)))
  1586. WHERE ((T181._Fld595 = ?)) AND ((0x08 <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1587. 0x01 AS Q_002_F_000_
  1588. FROM dbo._InfoRg11710 T185
  1589. WHERE ((T185._Fld595 = ?)) AND ((T185._Fld12072RRef = T181._IDRRef) AND (T185._Fld12073_TYPE = 0x08 AND T185._Fld12073_RTRef = 0x0000006E AND T185._Fld12073_RRRef = T179._Fld6064RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1590. 0x01 AS Q_003_F_000_
  1591. FROM dbo._InfoRg11715 T186
  1592. WHERE ((T186._Fld595 = ?)) AND ((T186._Fld12199RRef = T181._IDRRef) AND T186._Fld12200_TYPE = 0x08 AND T186._Fld12200_RTRef = 0x0000006E AND (T186._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END))))) AND (T179._Fld595 = ?)) T178
  1593. ON T93.RecorderTRef = 0x00000102 AND T93.RecorderRRef = T178.IDRRef
  1594. LEFT OUTER JOIN (SELECT
  1595. T188._IDRRef AS IDRRef,
  1596. T188._Fld3438RRef AS Fld3438RRef,
  1597. T188._Fld3444_TYPE AS Fld3444_TYPE,
  1598. T188._Fld3444_RTRef AS Fld3444_RTRef,
  1599. T188._Fld3444_RRRef AS Fld3444_RRRef,
  1600. T188._Fld595 AS Fld595_
  1601. FROM dbo._Document211 T188
  1602. WHERE ((EXISTS(SELECT
  1603. 1
  1604. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1605. LEFT OUTER JOIN dbo._Reference42 T189
  1606. ON ((T188._Fld3438RRef = T189._IDRRef)) AND (T189._Fld595 = ?)
  1607. WHERE EXISTS(SELECT
  1608. 0x01 AS Q_001_F_000_
  1609. FROM dbo._Reference98 T190
  1610. INNER JOIN dbo._Reference21 T191
  1611. ON (((T190._Fld1685 = ?) AND EXISTS(SELECT
  1612. 0x01 AS Q_004_F_000_
  1613. FROM dbo._InfoRg11709 T192
  1614. WHERE ((T192._Fld595 = ?)) AND ((T192._Fld12065RRef = T190._IDRRef) AND (T192._Fld12066RRef = T191._IDRRef)))) AND T191._IDRRef IN
  1615. (SELECT
  1616. T193._Reference21_IDRRef AS Q_005_F_000RRef
  1617. FROM dbo._Reference21_VT782 T193
  1618. INNER JOIN dbo._InfoRg9937 T194
  1619. ON ((T194._Fld9939_TYPE = 0x08 AND T194._Fld9939_RTRef = 0x00000095 AND T194._Fld9939_RRRef = ?) AND (T194._Fld9938_TYPE = T193._Fld784_TYPE AND T194._Fld9938_RTRef = T193._Fld784_RTRef AND T194._Fld9938_RRRef = T193._Fld784_RRRef))
  1620. WHERE ((T193._Fld595 = ?)) AND (T194._Fld595 = ?)))
  1621. WHERE ((T191._Fld595 = ?)) AND ((CASE WHEN T189._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T189._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1622. 0x01 AS Q_002_F_000_
  1623. FROM dbo._InfoRg11710 T195
  1624. WHERE ((T195._Fld595 = ?)) AND ((T195._Fld12072RRef = T191._IDRRef) AND (T195._Fld12073_TYPE = CASE WHEN T189._Fld12836RRef IS NOT NULL THEN 0x08 END AND T195._Fld12073_RTRef = CASE WHEN T189._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T195._Fld12073_RRRef = T189._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1625. 0x01 AS Q_003_F_000_
  1626. FROM dbo._InfoRg11715 T196
  1627. WHERE ((T196._Fld595 = ?)) AND ((T196._Fld12199RRef = T191._IDRRef) AND T196._Fld12200_TYPE = CASE WHEN T189._Fld12836RRef IS NOT NULL THEN 0x08 END AND T196._Fld12200_RTRef = CASE WHEN T189._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T196._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T188._Fld595 = ?)) T187
  1628. ON T93.RecorderTRef = 0x000000D3 AND T93.RecorderRRef = T187.IDRRef
  1629. LEFT OUTER JOIN dbo._Document248 T197
  1630. ON (T93.RecorderTRef = 0x000000F8 AND T93.RecorderRRef = T197._IDRRef) AND (T197._Fld595 = ?)
  1631. LEFT OUTER JOIN (SELECT
  1632. T199._Fld5855RRef AS Fld5855RRef,
  1633. T199._IDRRef AS IDRRef,
  1634. T199._Fld5860_TYPE AS Fld5860_TYPE,
  1635. T199._Fld5860_RTRef AS Fld5860_RTRef,
  1636. T199._Fld5860_RRRef AS Fld5860_RRRef,
  1637. T199._Fld595 AS Fld595_
  1638. FROM dbo._Document255 T199
  1639. WHERE ((EXISTS(SELECT
  1640. 1
  1641. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1642. LEFT OUTER JOIN dbo._Reference42 T200
  1643. ON ((T199._Fld5855RRef = T200._IDRRef)) AND (T200._Fld595 = ?)
  1644. WHERE EXISTS(SELECT
  1645. 0x01 AS Q_001_F_000_
  1646. FROM dbo._Reference98 T201
  1647. INNER JOIN dbo._Reference21 T202
  1648. ON (((T201._Fld1685 = ?) AND EXISTS(SELECT
  1649. 0x01 AS Q_004_F_000_
  1650. FROM dbo._InfoRg11709 T203
  1651. WHERE ((T203._Fld595 = ?)) AND ((T203._Fld12065RRef = T201._IDRRef) AND (T203._Fld12066RRef = T202._IDRRef)))) AND T202._IDRRef IN
  1652. (SELECT
  1653. T204._Reference21_IDRRef AS Q_005_F_000RRef
  1654. FROM dbo._Reference21_VT782 T204
  1655. INNER JOIN dbo._InfoRg9937 T205
  1656. ON ((T205._Fld9939_TYPE = 0x08 AND T205._Fld9939_RTRef = 0x00000095 AND T205._Fld9939_RRRef = ?) AND (T205._Fld9938_TYPE = T204._Fld784_TYPE AND T205._Fld9938_RTRef = T204._Fld784_RTRef AND T205._Fld9938_RRRef = T204._Fld784_RRRef))
  1657. WHERE ((T204._Fld595 = ?)) AND (T205._Fld595 = ?)))
  1658. WHERE ((T202._Fld595 = ?)) AND ((CASE WHEN T200._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T200._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1659. 0x01 AS Q_002_F_000_
  1660. FROM dbo._InfoRg11710 T206
  1661. WHERE ((T206._Fld595 = ?)) AND ((T206._Fld12072RRef = T202._IDRRef) AND (T206._Fld12073_TYPE = CASE WHEN T200._Fld12836RRef IS NOT NULL THEN 0x08 END AND T206._Fld12073_RTRef = CASE WHEN T200._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T206._Fld12073_RRRef = T200._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1662. 0x01 AS Q_003_F_000_
  1663. FROM dbo._InfoRg11715 T207
  1664. WHERE ((T207._Fld595 = ?)) AND ((T207._Fld12199RRef = T202._IDRRef) AND T207._Fld12200_TYPE = CASE WHEN T200._Fld12836RRef IS NOT NULL THEN 0x08 END AND T207._Fld12200_RTRef = CASE WHEN T200._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T207._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T199._Fld595 = ?)) T198
  1665. ON T93.RecorderTRef = 0x000000FF AND T93.RecorderRRef = T198.IDRRef
  1666. LEFT OUTER JOIN dbo._Document210 T208
  1667. ON (T93.RecorderTRef = 0x000000D2 AND T93.RecorderRRef = T208._IDRRef) AND (T208._Fld595 = ?)
  1668. WHERE (NOT (((CASE WHEN T93.RecorderTRef = 0x000000E9 THEN T112.Fld4634_TYPE WHEN T93.RecorderTRef = 0x000000D4 THEN CASE WHEN T122._Fld3521RRef IS NOT NULL THEN 0x08 END WHEN T93.RecorderTRef = 0x000000EA THEN T123.Fld4782_TYPE WHEN T93.RecorderTRef = 0x000000FD THEN T135._Fld5727_TYPE WHEN T93.RecorderTRef = 0x00000103 THEN T136.Fld6145_TYPE WHEN T93.RecorderTRef = 0x000000D8 THEN T146.Fld3852_TYPE WHEN T93.RecorderTRef = 0x000000D1 THEN T156.Fld3325_TYPE WHEN T93.RecorderTRef = 0x000000D7 THEN CASE WHEN T168.Fld3739RRef IS NOT NULL THEN 0x08 END WHEN T93.RecorderTRef = 0x00000102 THEN T178.Fld6057_TYPE WHEN T93.RecorderTRef = 0x000000D3 THEN T187.Fld3444_TYPE WHEN T93.RecorderTRef = 0x000000F8 THEN CASE WHEN T197._Fld5366RRef IS NOT NULL THEN 0x08 END WHEN T93.RecorderTRef = 0x000000FF THEN T198.Fld5860_TYPE WHEN T93.RecorderTRef = 0x000000D2 THEN T208._Fld3350_TYPE ELSE CAST(NULL AS BINARY(1)) END = 0x08 AND CASE WHEN T93.RecorderTRef = 0x000000E9 THEN T112.Fld4634_RTRef WHEN T93.RecorderTRef = 0x000000D4 THEN CASE WHEN T122._Fld3521RRef IS NOT NULL THEN 0x000000E9 END WHEN T93.RecorderTRef = 0x000000EA THEN T123.Fld4782_RTRef WHEN T93.RecorderTRef = 0x000000FD THEN T135._Fld5727_RTRef WHEN T93.RecorderTRef = 0x00000103 THEN T136.Fld6145_RTRef WHEN T93.RecorderTRef = 0x000000D8 THEN T146.Fld3852_RTRef WHEN T93.RecorderTRef = 0x000000D1 THEN T156.Fld3325_RTRef WHEN T93.RecorderTRef = 0x000000D7 THEN CASE WHEN T168.Fld3739RRef IS NOT NULL THEN 0x000000E9 END WHEN T93.RecorderTRef = 0x00000102 THEN T178.Fld6057_RTRef WHEN T93.RecorderTRef = 0x000000D3 THEN T187.Fld3444_RTRef WHEN T93.RecorderTRef = 0x000000F8 THEN CASE WHEN T197._Fld5366RRef IS NOT NULL THEN 0x000000F9 END WHEN T93.RecorderTRef = 0x000000FF THEN T198.Fld5860_RTRef WHEN T93.RecorderTRef = 0x000000D2 THEN T208._Fld3350_RTRef ELSE CAST(NULL AS BINARY(4)) END = 0x000000D3)))) AND ((T93.RecorderTRef = 0x00000103) OR (T93.RecorderTRef = 0x000000FF))
  1669. UNION ALL SELECT
  1670. T209.Fld10332_TYPE,
  1671. T209.Fld10332_RTRef,
  1672. T209.Fld10332_RRRef,
  1673. T209.Fld10328RRef,
  1674. CAST(NULL AS NUMERIC(28, 2)),
  1675. T209.Fld10330RRef,
  1676. CAST(NULL AS NUMERIC(21, 2)),
  1677. T219.Fld12836RRef
  1678. FROM (SELECT
  1679. T210._RecorderTRef AS RecorderTRef,
  1680. T210._RecorderRRef AS RecorderRRef,
  1681. T210._Fld10332_TYPE AS Fld10332_TYPE,
  1682. T210._Fld10332_RTRef AS Fld10332_RTRef,
  1683. T210._Fld10332_RRRef AS Fld10332_RRRef,
  1684. T210._Fld10328RRef AS Fld10328RRef,
  1685. T210._Fld10330RRef AS Fld10330RRef,
  1686. CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN T210._Fld10334 ELSE 0.0 END) AS NUMERIC(27, 8)) AS Fld10334Receipt_,
  1687. CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN 0.0 ELSE T210._Fld10334 END) AS NUMERIC(27, 8)) AS Fld10334Expense_,
  1688. CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN T210._Fld10335 ELSE 0.0 END) AS NUMERIC(27, 8)) AS Fld10335Receipt_,
  1689. CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN 0.0 ELSE T210._Fld10335 END) AS NUMERIC(27, 8)) AS Fld10335Expense_
  1690. FROM dbo._AccumRg10327 T210
  1691. WHERE (((T210._Fld595 = ?)) AND (EXISTS(SELECT
  1692. 1
  1693. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  1694. LEFT OUTER JOIN dbo._Reference42 T211
  1695. ON ((T210._Fld10330RRef = T211._IDRRef)) AND (T211._Fld595 = ?)
  1696. WHERE EXISTS(SELECT
  1697. 0x01 AS Q_001_F_000_
  1698. FROM dbo._Reference98 T212
  1699. INNER JOIN dbo._Reference21 T213
  1700. ON (((T212._Fld1685 = ?) AND EXISTS(SELECT
  1701. 0x01 AS Q_004_F_000_
  1702. FROM dbo._InfoRg11709 T214
  1703. WHERE ((T214._Fld595 = ?)) AND ((T214._Fld12065RRef = T212._IDRRef) AND (T214._Fld12066RRef = T213._IDRRef)))) AND T213._IDRRef IN
  1704. (SELECT
  1705. T215._Reference21_IDRRef AS Q_005_F_000RRef
  1706. FROM dbo._Reference21_VT782 T215
  1707. INNER JOIN dbo._InfoRg9937 T216
  1708. ON ((T216._Fld9939_TYPE = 0x08 AND T216._Fld9939_RTRef = 0x00000095 AND T216._Fld9939_RRRef = ?) AND (T216._Fld9938_TYPE = T215._Fld784_TYPE AND T216._Fld9938_RTRef = T215._Fld784_RTRef AND T216._Fld9938_RRRef = T215._Fld784_RRRef))
  1709. WHERE ((T215._Fld595 = ?)) AND (T216._Fld595 = ?)))
  1710. WHERE ((T213._Fld595 = ?)) AND ((CASE WHEN T211._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T211._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1711. 0x01 AS Q_002_F_000_
  1712. FROM dbo._InfoRg11710 T217
  1713. WHERE ((T217._Fld595 = ?)) AND ((T217._Fld12072RRef = T213._IDRRef) AND (T217._Fld12073_TYPE = CASE WHEN T211._Fld12836RRef IS NOT NULL THEN 0x08 END AND T217._Fld12073_RTRef = CASE WHEN T211._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T217._Fld12073_RRRef = T211._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1714. 0x01 AS Q_003_F_000_
  1715. FROM dbo._InfoRg11715 T218
  1716. WHERE ((T218._Fld595 = ?)) AND ((T218._Fld12199RRef = T213._IDRRef) AND T218._Fld12200_TYPE = CASE WHEN T211._Fld12836RRef IS NOT NULL THEN 0x08 END AND T218._Fld12200_RTRef = CASE WHEN T211._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T218._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T210._Period >= ? AND T210._Period <= ? AND T210._Active = 0x01)
  1717. GROUP BY T210._RecorderTRef,
  1718. T210._RecorderRRef,
  1719. T210._Fld10332_TYPE,
  1720. T210._Fld10332_RTRef,
  1721. T210._Fld10332_RRRef,
  1722. T210._Fld10328RRef,
  1723. T210._Fld10330RRef
  1724. HAVING (CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN T210._Fld10334 ELSE 0.0 END) AS NUMERIC(27, 8))) <> 0.0 OR (CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN 0.0 ELSE T210._Fld10334 END) AS NUMERIC(27, 8))) <> 0.0 OR (CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN T210._Fld10335 ELSE 0.0 END) AS NUMERIC(27, 8))) <> 0.0 OR (CAST(SUM(CASE WHEN T210._RecordKind = 0.0 THEN 0.0 ELSE T210._Fld10335 END) AS NUMERIC(27, 8))) <> 0.0) T209
  1725. LEFT OUTER JOIN (SELECT
  1726. T220._IDRRef AS IDRRef,
  1727. T220._Fld12836RRef AS Fld12836RRef,
  1728. T220._Fld595 AS Fld595_,
  1729. T220._Folder AS Folder_
  1730. FROM dbo._Reference42 T220
  1731. WHERE ((((T220._Folder = 0x00) OR EXISTS(SELECT
  1732. 0x01 AS Q_001_F_000_
  1733. FROM dbo._Reference98 T221
  1734. INNER JOIN dbo._Reference21 T222
  1735. ON (((T221._Fld1685 = ?) AND EXISTS(SELECT
  1736. 0x01 AS Q_004_F_000_
  1737. FROM dbo._InfoRg11709 T223
  1738. WHERE ((T223._Fld595 = ?)) AND ((T223._Fld12065RRef = T221._IDRRef) AND (T223._Fld12066RRef = T222._IDRRef)))) AND T222._IDRRef IN
  1739. (SELECT
  1740. T224._Reference21_IDRRef AS Q_005_F_000RRef
  1741. FROM dbo._Reference21_VT782 T224
  1742. INNER JOIN dbo._InfoRg9937 T225
  1743. ON ((T225._Fld9939_TYPE = 0x08 AND T225._Fld9939_RTRef = 0x00000095 AND T225._Fld9939_RRRef = ?) AND (T225._Fld9938_TYPE = T224._Fld784_TYPE AND T225._Fld9938_RTRef = T224._Fld784_RTRef AND T225._Fld9938_RRRef = T224._Fld784_RRRef))
  1744. WHERE ((T224._Fld595 = ?)) AND (T225._Fld595 = ?)))
  1745. WHERE ((T222._Fld595 = ?)) AND ((CASE WHEN T220._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T220._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  1746. 0x01 AS Q_002_F_000_
  1747. FROM dbo._InfoRg11710 T226
  1748. WHERE ((T226._Fld595 = ?)) AND ((T226._Fld12072RRef = T222._IDRRef) AND (T226._Fld12073_TYPE = CASE WHEN T220._Fld12836RRef IS NOT NULL THEN 0x08 END AND T226._Fld12073_RTRef = CASE WHEN T220._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T226._Fld12073_RRRef = T220._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  1749. 0x01 AS Q_003_F_000_
  1750. FROM dbo._InfoRg11715 T227
  1751. WHERE ((T227._Fld595 = ?)) AND ((T227._Fld12199RRef = T222._IDRRef) AND T227._Fld12200_TYPE = CASE WHEN T220._Fld12836RRef IS NOT NULL THEN 0x08 END AND T227._Fld12200_RTRef = CASE WHEN T220._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T227._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T220._Fld595 = ?)) T219
  1752. ON T209.Fld10330RRef = T219.IDRRef
  1753. WHERE (T209.RecorderTRef = 0x000000D1)
Add Comment
Please, Sign In to add comment