Advertisement
bytecoded

Top 1 Query SQL

Mar 23rd, 2019
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 15.53 KB | None | 0 0
  1. (@P1 NUMERIC(10),@P2 varbinary(16),@P3 NUMERIC(10),@P4 NUMERIC(10),@P5 NUMERIC(10),@P6 nvarchar(4000),@P7 NUMERIC(10),@P8 varbinary(16),@P9 NUMERIC(10),@P10 NUMERIC(10),@P11 NUMERIC(10),@P12 NUMERIC(10),@P13 NUMERIC(10),@P14 datetime2(3),@P15 varbinary(16),@P16 NUMERIC(10),@P17 NUMERIC(10),@P18 NUMERIC(10),@P19 datetime2(3),@P20 varbinary(16),@P21 NUMERIC(10),@P22 NUMERIC(10),@P23 NUMERIC(10),@P24 datetime2(3),@P25 datetime2(3),@P26 varbinary(16),@P27 NUMERIC(10),@P28 NUMERIC(10),@P29 NUMERIC(10),@P30 NUMERIC(10),@P31 nvarchar(4000),@P32 NUMERIC(10),@P33 varbinary(16),@P34 NUMERIC(10),@P35 NUMERIC(10),@P36 NUMERIC(10),@P37 NUMERIC(10),@P38 NUMERIC(10),@P39 datetime2(3),@P40 varbinary(16),@P41 NUMERIC(10),@P42 NUMERIC(10),@P43 NUMERIC(10),@P44 NUMERIC(10),@P45 NUMERIC(10),@P46 nvarchar(4000),@P47 NUMERIC(10),@P48 varbinary(16),@P49 NUMERIC(10),@P50 NUMERIC(10),@P51 NUMERIC(10),@P52 NUMERIC(10),@P53 NUMERIC(10),@P54 varbinary(16),@P55 varbinary(16),@P56 datetime2(3),@P57 varbinary(16),@P58 NUMERIC(10),@P59 NUMERIC(10),@P60 NUMERIC(10),@P61 NUMERIC(10),@P62 NUMERIC(10),@P63 NUMERIC(10),@P64 NUMERIC(10),@P65 NUMERIC(10),@P66 NUMERIC(10),@P67 NUMERIC(10),@P68 NUMERIC(10),@P69 NUMERIC(10),@P70 NUMERIC(10),@P71 NUMERIC(10),@P72 NUMERIC(10),@P73 NUMERIC(10),@P74 NUMERIC(10),@P75 NUMERIC(10),@P76 NUMERIC(10),@P77 NUMERIC(10),@P78 NUMERIC(10),@P79 NUMERIC(10),@P80 NUMERIC(10),@P81 NUMERIC(10),@P82 NUMERIC(10),@P83 NUMERIC(10),@P84 NUMERIC(10),@P85 NUMERIC(10),@P86 NUMERIC(10),@P87 NUMERIC(10),@P88 varbinary(16),@P89 NUMERIC(10),@P90 NUMERIC(10),@P91 NUMERIC(10),@P92 NUMERIC(10),@P93 NUMERIC(10),@P94 NUMERIC(10),@P95 NUMERIC(10),@P96 NUMERIC(10),@P97 NUMERIC(10),@P98 NUMERIC(10),@P99 NUMERIC(10),@P100 NUMERIC(10),@P101 NUMERIC(10),@P102 NUMERIC(10),@P103 NUMERIC(10),@P104 NUMERIC(10),@P105 NUMERIC(10),@P106 NUMERIC(10),@P107 NUMERIC(10),@P108 NUMERIC(10),@P109 NUMERIC(10),@P110 NUMERIC(10),@P111 NUMERIC(10),@P112 NUMERIC(10),@P113 NUMERIC(10),@P114 NUMERIC(10),@P115 NUMERIC(10),@P116 NUMERIC(10),@P117 NUMERIC(10),@P118 NUMERIC(10),@P119 varbinary(16))SELECT TOP 25
  2. T1._IDRRef,
  3. T1._Marked,
  4. T1._Number,
  5. T1._Date_Time,
  6. T1._Posted,
  7. T1._Fld4621RRef,
  8. T1._Fld4622RRef,
  9. T1._Fld4625RRef,
  10. T1._Fld4627RRef,
  11. T1._Fld4633,
  12. T1._Fld4635RRef,
  13. T1._Fld4657RRef,
  14. CASE WHEN ((T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T14.Fld10346Balance_ AS NUMERIC(33, 2)),0.0) > 0.0) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 4.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 6.0 ELSE 5.0 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 0.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 2.0 ELSE 1.0 END END ELSE 7.0 END,
  15. T19._Fld12313RRef,
  16. T1._Fld13369,
  17. CASE WHEN ((ISNULL(CAST(T20.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) > 0.0) THEN (ISNULL(CAST(T20.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) ELSE 0.0 END,
  18. T30._Fld1191
  19. FROM dbo._Document233 T1
  20. LEFT OUTER JOIN (SELECT
  21. T3._Fld11328RRef AS Fld11328RRef,
  22. CAST(SUM(T3._Fld11330) AS NUMERIC(33, 8)) AS Fld11330Turnover_
  23. FROM dbo._AccumRgTn11332 T3
  24. WHERE ((T3._Fld595 = @P1)) AND (((T3._Fld11324RRef = @P2)) AND (T3._Fld11330 <> @P3))
  25. GROUP BY T3._Fld11328RRef
  26. HAVING (CAST(SUM(T3._Fld11330) AS NUMERIC(33, 8))) <> 0.0) T2
  27. ON (T1._IDRRef = T2.Fld11328RRef)
  28. LEFT OUTER JOIN (SELECT
  29. T5._Fld10540_TYPE AS Fld10540_TYPE,
  30. T5._Fld10540_RTRef AS Fld10540_RTRef,
  31. T5._Fld10540_RRRef AS Fld10540_RRRef,
  32. CAST(SUM(T5._Fld10545) AS NUMERIC(33, 8)) AS Fld10545Balance_
  33. FROM dbo._AccumRgT10549 T5
  34. WHERE (((T5._Fld595 = @P4)) AND (EXISTS(SELECT
  35. 1
  36. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  37. LEFT OUTER JOIN dbo._Reference42 T6
  38. ON ((T5._Fld10538RRef = T6._IDRRef)) AND (T6._Fld595 = @P5)
  39. WHERE EXISTS(SELECT
  40. 0x01 AS Q_001_F_000_
  41. FROM dbo._Reference98 T7
  42. INNER JOIN dbo._Reference21 T8
  43. ON (((T7._Fld1685 = @P6) AND EXISTS(SELECT
  44. 0x01 AS Q_004_F_000_
  45. FROM dbo._InfoRg11709 T9
  46. WHERE ((T9._Fld595 = @P7)) AND ((T9._Fld12065RRef = T7._IDRRef) AND (T9._Fld12066RRef = T8._IDRRef)))) AND T8._IDRRef IN
  47. (SELECT
  48. T10._Reference21_IDRRef AS Q_005_F_000RRef
  49. FROM dbo._Reference21_VT782 T10
  50. INNER JOIN dbo._InfoRg9937 T11
  51. ON ((T11._Fld9939_TYPE = 0x08 AND T11._Fld9939_RTRef = 0x00000095 AND T11._Fld9939_RRRef = @P8) AND (T11._Fld9938_TYPE = T10._Fld784_TYPE AND T11._Fld9938_RTRef = T10._Fld784_RTRef AND T11._Fld9938_RRRef = T10._Fld784_RRRef))
  52. WHERE ((T10._Fld595 = @P9)) AND (T11._Fld595 = @P10)))
  53. WHERE ((T8._Fld595 = @P11)) AND ((CASE WHEN T6._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T6._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  54. 0x01 AS Q_002_F_000_
  55. FROM dbo._InfoRg11710 T12
  56. WHERE ((T12._Fld595 = @P12)) AND ((T12._Fld12072RRef = T8._IDRRef) AND (T12._Fld12073_TYPE = CASE WHEN T6._Fld12836RRef IS NOT NULL THEN 0x08 END AND T12._Fld12073_RTRef = CASE WHEN T6._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T12._Fld12073_RRRef = T6._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  57. 0x01 AS Q_003_F_000_
  58. FROM dbo._InfoRg11715 T13
  59. WHERE ((T13._Fld595 = @P13)) AND ((T13._Fld12199RRef = T8._IDRRef) AND T13._Fld12200_TYPE = CASE WHEN T6._Fld12836RRef IS NOT NULL THEN 0x08 END AND T13._Fld12200_RTRef = CASE WHEN T6._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T13._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T5._Period = @P14 AND ((T5._Fld10536RRef = @P15)) AND (T5._Fld10545 <> @P16) AND (T5._Fld10545 <> @P17))
  60. GROUP BY T5._Fld10540_TYPE,
  61. T5._Fld10540_RTRef,
  62. T5._Fld10540_RRRef
  63. HAVING (CAST(SUM(T5._Fld10545) AS NUMERIC(33, 8))) <> 0.0) T4
  64. ON (0x08 = T4.Fld10540_TYPE AND 0x000000E9 = T4.Fld10540_RTRef AND T1._IDRRef = T4.Fld10540_RRRef)
  65. LEFT OUTER JOIN (SELECT
  66. T15.Fld10344RRef AS Fld10344RRef,
  67. CAST(SUM(T15.Fld10346Balance_) AS NUMERIC(38, 8)) AS Fld10346Balance_
  68. FROM (SELECT
  69. T16._Fld10344RRef AS Fld10344RRef,
  70. CAST(SUM(T16._Fld10346) AS NUMERIC(33, 8)) AS Fld10346Balance_
  71. FROM dbo._AccumRgT10349 T16
  72. WHERE ((T16._Fld595 = @P18)) AND (T16._Period = @P19 AND ((T16._Fld10340RRef = @P20)) AND (T16._Fld10346 <> @P21) AND (T16._Fld10346 <> @P22))
  73. GROUP BY T16._Fld10344RRef
  74. HAVING (CAST(SUM(T16._Fld10346) AS NUMERIC(33, 8))) <> 0.0
  75. UNION ALL SELECT
  76. T17._Fld10344RRef AS Fld10344RRef,
  77. CAST(CAST(SUM(CASE WHEN T17._RecordKind = 0.0 THEN -T17._Fld10346 ELSE T17._Fld10346 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld10346Balance_
  78. FROM dbo._AccumRg10339 T17
  79. WHERE ((T17._Fld595 = @P23)) AND (T17._Period >= @P24 AND T17._Period < @P25 AND T17._Active = 0x01 AND ((T17._Fld10340RRef = @P26)))
  80. GROUP BY T17._Fld10344RRef
  81. HAVING (CAST(CAST(SUM(CASE WHEN T17._RecordKind = 0.0 THEN -T17._Fld10346 ELSE T17._Fld10346 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2))) <> 0.0) T15
  82. GROUP BY T15.Fld10344RRef
  83. HAVING (CAST(SUM(T15.Fld10346Balance_) AS NUMERIC(38, 8))) <> 0.0) T14
  84. ON (T1._IDRRef = T14.Fld10344RRef)
  85. LEFT OUTER JOIN dbo._InfoRg9134 T18
  86. ON ((0x08 = T18._Fld9136_TYPE AND 0x000000E9 = T18._Fld9136_RTRef AND T1._IDRRef = T18._Fld9136_RRRef)) AND (T18._Fld595 = @P27)
  87. LEFT OUTER JOIN dbo._InfoRg11720 T19
  88. ON ((0x08 = T19._Fld12312_TYPE AND 0x000000E9 = T19._Fld12312_RTRef AND T1._IDRRef = T19._Fld12312_RRRef)) AND (T19._Fld595 = @P28)
  89. LEFT OUTER JOIN (SELECT
  90. T21._Fld10332_TYPE AS Fld10332_TYPE,
  91. T21._Fld10332_RTRef AS Fld10332_RTRef,
  92. T21._Fld10332_RRRef AS Fld10332_RRRef,
  93. CAST(SUM(T21._Fld10335) AS NUMERIC(33, 8)) AS Fld10335Balance_
  94. FROM dbo._AccumRgT10337 T21
  95. WHERE (((T21._Fld595 = @P29)) AND (EXISTS(SELECT
  96. 1
  97. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  98. LEFT OUTER JOIN dbo._Reference42 T22
  99. ON ((T21._Fld10330RRef = T22._IDRRef)) AND (T22._Fld595 = @P30)
  100. WHERE EXISTS(SELECT
  101. 0x01 AS Q_001_F_000_
  102. FROM dbo._Reference98 T23
  103. INNER JOIN dbo._Reference21 T24
  104. ON (((T23._Fld1685 = @P31) AND EXISTS(SELECT
  105. 0x01 AS Q_004_F_000_
  106. FROM dbo._InfoRg11709 T25
  107. WHERE ((T25._Fld595 = @P32)) AND ((T25._Fld12065RRef = T23._IDRRef) AND (T25._Fld12066RRef = T24._IDRRef)))) AND T24._IDRRef IN
  108. (SELECT
  109. T26._Reference21_IDRRef AS Q_005_F_000RRef
  110. FROM dbo._Reference21_VT782 T26
  111. INNER JOIN dbo._InfoRg9937 T27
  112. ON ((T27._Fld9939_TYPE = 0x08 AND T27._Fld9939_RTRef = 0x00000095 AND T27._Fld9939_RRRef = @P33) AND (T27._Fld9938_TYPE = T26._Fld784_TYPE AND T27._Fld9938_RTRef = T26._Fld784_RTRef AND T27._Fld9938_RRRef = T26._Fld784_RRRef))
  113. WHERE ((T26._Fld595 = @P34)) AND (T27._Fld595 = @P35)))
  114. WHERE ((T24._Fld595 = @P36)) AND ((CASE WHEN T22._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T22._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  115. 0x01 AS Q_002_F_000_
  116. FROM dbo._InfoRg11710 T28
  117. WHERE ((T28._Fld595 = @P37)) AND ((T28._Fld12072RRef = T24._IDRRef) AND (T28._Fld12073_TYPE = CASE WHEN T22._Fld12836RRef IS NOT NULL THEN 0x08 END AND T28._Fld12073_RTRef = CASE WHEN T22._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T28._Fld12073_RRRef = T22._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  118. 0x01 AS Q_003_F_000_
  119. FROM dbo._InfoRg11715 T29
  120. WHERE ((T29._Fld595 = @P38)) AND ((T29._Fld12199RRef = T24._IDRRef) AND T29._Fld12200_TYPE = CASE WHEN T22._Fld12836RRef IS NOT NULL THEN 0x08 END AND T29._Fld12200_RTRef = CASE WHEN T22._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T29._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T21._Period = @P39 AND ((T21._Fld10328RRef = @P40)) AND (T21._Fld10335 <> @P41) AND (T21._Fld10335 <> @P42))
  121. GROUP BY T21._Fld10332_TYPE,
  122. T21._Fld10332_RTRef,
  123. T21._Fld10332_RRRef
  124. HAVING (CAST(SUM(T21._Fld10335) AS NUMERIC(33, 8))) <> 0.0) T20
  125. ON (0x08 = T20.Fld10332_TYPE AND 0x000000E9 = T20.Fld10332_RTRef AND T1._IDRRef = T20.Fld10332_RRRef)
  126. LEFT OUTER JOIN dbo._Reference51 T30
  127. ON (T1._Fld4635RRef = T30._IDRRef) AND (T30._Fld595 = @P43)
  128. WHERE (((T1._Fld595 = @P44)) AND (EXISTS(SELECT
  129. 1
  130. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  131. LEFT OUTER JOIN dbo._Reference42 T31
  132. ON ((T1._Fld4625RRef = T31._IDRRef)) AND (T31._Fld595 = @P45)
  133. WHERE EXISTS(SELECT
  134. 0x01 AS Q_001_F_000_
  135. FROM dbo._Reference98 T32
  136. INNER JOIN dbo._Reference21 T33
  137. ON (((T32._Fld1685 = @P46) AND EXISTS(SELECT
  138. 0x01 AS Q_004_F_000_
  139. FROM dbo._InfoRg11709 T34
  140. WHERE ((T34._Fld595 = @P47)) AND ((T34._Fld12065RRef = T32._IDRRef) AND (T34._Fld12066RRef = T33._IDRRef)))) AND T33._IDRRef IN
  141. (SELECT
  142. T35._Reference21_IDRRef AS Q_005_F_000RRef
  143. FROM dbo._Reference21_VT782 T35
  144. INNER JOIN dbo._InfoRg9937 T36
  145. ON ((T36._Fld9939_TYPE = 0x08 AND T36._Fld9939_RTRef = 0x00000095 AND T36._Fld9939_RRRef = @P48) AND (T36._Fld9938_TYPE = T35._Fld784_TYPE AND T36._Fld9938_RTRef = T35._Fld784_RTRef AND T36._Fld9938_RRRef = T35._Fld784_RRRef))
  146. WHERE ((T35._Fld595 = @P49)) AND (T36._Fld595 = @P50)))
  147. WHERE ((T33._Fld595 = @P51)) AND ((CASE WHEN T31._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T31._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  148. 0x01 AS Q_002_F_000_
  149. FROM dbo._InfoRg11710 T37
  150. WHERE ((T37._Fld595 = @P52)) AND ((T37._Fld12072RRef = T33._IDRRef) AND (T37._Fld12073_TYPE = CASE WHEN T31._Fld12836RRef IS NOT NULL THEN 0x08 END AND T37._Fld12073_RTRef = CASE WHEN T31._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T37._Fld12073_RRRef = T31._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  151. 0x01 AS Q_003_F_000_
  152. FROM dbo._InfoRg11715 T38
  153. WHERE ((T38._Fld595 = @P53)) AND ((T38._Fld12199RRef = T33._IDRRef) AND T38._Fld12200_TYPE = CASE WHEN T31._Fld12836RRef IS NOT NULL THEN 0x08 END AND T38._Fld12200_RTRef = CASE WHEN T31._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T38._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND ((T1._Fld4636RRef = @P54) AND (T1._Fld4621RRef = @P55) AND (T1._Date_Time >= @P56) AND ((CASE WHEN ((T1._Fld4657RRef = @P57) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T14.Fld10346Balance_ AS NUMERIC(33, 2)),@P58) > @P59) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P60) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P61)) THEN @P62 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P63) = @P64) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P65) > @P66)) THEN @P67 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P68) AS NUMERIC(33, 8)) / @P69) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P70)) THEN @P71 ELSE @P72 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P73) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P74)) THEN @P75 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P76) = @P77) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P78) > @P79)) THEN @P80 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P81) AS NUMERIC(33, 8)) / @P82) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P83)) THEN @P84 ELSE @P85 END END ELSE @P86 END > @P87) OR ((CASE WHEN ((T1._Fld4657RRef = @P88) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T14.Fld10346Balance_ AS NUMERIC(33, 2)),@P89) > @P90) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P91) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P92)) THEN @P93 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P94) = @P95) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P96) > @P97)) THEN @P98 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P99) AS NUMERIC(33, 8)) / @P100) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P101)) THEN @P102 ELSE @P103 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P104) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P105)) THEN @P106 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P107) = @P108) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P109) > @P110)) THEN @P111 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P112) AS NUMERIC(33, 8)) / @P113) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P114)) THEN @P115 ELSE @P116 END END ELSE @P117 END = @P118) AND (T1._IDRRef >= @P119))))
  154. ORDER BY (CASE WHEN ((T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T14.Fld10346Balance_ AS NUMERIC(33, 2)),0.0) > 0.0) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 4.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 6.0 ELSE 5.0 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 0.0 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 2.0 ELSE 1.0 END END ELSE 7.0 END), (T1._IDRRef)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement