Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (@P1 NUMERIC(10),@P2 NUMERIC(10),@P3 NUMERIC(10),@P4 datetime2(3),@P5 NUMERIC(10),@P6 NUMERIC(10),@P7 NUMERIC(10),@P8 datetime2(3),@P9 NUMERIC(10),@P10 NUMERIC(10),@P11 NUMERIC(10),@P12 datetime2(3),@P13 datetime2(3),@P14 NUMERIC(10),@P15 NUMERIC(10),@P16 NUMERIC(10),@P17 datetime2(3),@P18 NUMERIC(10),@P19 NUMERIC(10),@P20 NUMERIC(10),@P21 NUMERIC(10),@P22 varbinary(16),@P23 varbinary(16),@P24 NUMERIC(10),@P25 NUMERIC(10),@P26 NUMERIC(10),@P27 NUMERIC(10),@P28 NUMERIC(10),@P29 NUMERIC(10),@P30 NUMERIC(10),@P31 NUMERIC(10),@P32 NUMERIC(10),@P33 NUMERIC(10),@P34 NUMERIC(10),@P35 NUMERIC(10),@P36 NUMERIC(10),@P37 NUMERIC(10),@P38 NUMERIC(10),@P39 NUMERIC(10),@P40 NUMERIC(10),@P41 NUMERIC(10),@P42 NUMERIC(10),@P43 NUMERIC(10),@P44 NUMERIC(10),@P45 NUMERIC(10),@P46 NUMERIC(10),@P47 NUMERIC(10),@P48 NUMERIC(10),@P49 NUMERIC(10),@P50 NUMERIC(10),@P51 NUMERIC(10),@P52 NUMERIC(10),@P53 NUMERIC(10),@P54 varbinary(16),@P55 NUMERIC(10),@P56 NUMERIC(10),@P57 NUMERIC(10),@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 varbinary(16))SELECT TOP 25
- T1._IDRRef,
- T1._Marked,
- T1._Number,
- T1._Date_Time,
- T1._Posted,
- T1._Fld4621RRef,
- T1._Fld4622RRef,
- T1._Fld4625RRef,
- T1._Fld4633,
- T1._Fld4635RRef,
- T1._Fld4657RRef,
- CASE WHEN ((T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.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,
- T11._Fld12313RRef,
- CASE WHEN ((ISNULL(CAST(T12.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) > 0.0) THEN (ISNULL(CAST(T12.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) ELSE 0.0 END,
- T14._Fld1191
- FROM dbo._Document233 T1
- LEFT OUTER JOIN (SELECT
- T3._Fld11328RRef AS Fld11328RRef,
- CAST(SUM(T3._Fld11330) AS NUMERIC(33, 8)) AS Fld11330Turnover_
- FROM dbo._AccumRgTn11332 T3
- WHERE ((T3._Fld595 = @P1)) AND ((T3._Fld11330 <> @P2))
- GROUP BY T3._Fld11328RRef
- HAVING (CAST(SUM(T3._Fld11330) AS NUMERIC(33, 8))) <> 0.0) T2
- ON (T1._IDRRef = T2.Fld11328RRef)
- LEFT OUTER JOIN (SELECT
- T5._Fld10540_TYPE AS Fld10540_TYPE,
- T5._Fld10540_RTRef AS Fld10540_RTRef,
- T5._Fld10540_RRRef AS Fld10540_RRRef,
- CAST(SUM(T5._Fld10545) AS NUMERIC(33, 8)) AS Fld10545Balance_
- FROM dbo._AccumRgT10549 T5
- WHERE ((T5._Fld595 = @P3)) AND (T5._Period = @P4 AND (T5._Fld10545 <> @P5) AND (T5._Fld10545 <> @P6))
- GROUP BY T5._Fld10540_TYPE,
- T5._Fld10540_RTRef,
- T5._Fld10540_RRRef
- HAVING (CAST(SUM(T5._Fld10545) AS NUMERIC(33, 8))) <> 0.0) T4
- ON (0x08 = T4.Fld10540_TYPE AND 0x000000E9 = T4.Fld10540_RTRef AND T1._IDRRef = T4.Fld10540_RRRef)
- LEFT OUTER JOIN (SELECT
- T7.Fld10344RRef AS Fld10344RRef,
- CAST(SUM(T7.Fld10346Balance_) AS NUMERIC(38, 8)) AS Fld10346Balance_
- FROM (SELECT
- T8._Fld10344RRef AS Fld10344RRef,
- CAST(SUM(T8._Fld10346) AS NUMERIC(33, 8)) AS Fld10346Balance_
- FROM dbo._AccumRgT10349 T8
- WHERE ((T8._Fld595 = @P7)) AND (T8._Period = @P8 AND (T8._Fld10346 <> @P9) AND (T8._Fld10346 <> @P10))
- GROUP BY T8._Fld10344RRef
- HAVING (CAST(SUM(T8._Fld10346) AS NUMERIC(33, 8))) <> 0.0
- UNION ALL SELECT
- T9._Fld10344RRef AS Fld10344RRef,
- CAST(CAST(SUM(CASE WHEN T9._RecordKind = 0.0 THEN -T9._Fld10346 ELSE T9._Fld10346 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2)) AS Fld10346Balance_
- FROM dbo._AccumRg10339 T9
- WHERE ((T9._Fld595 = @P11)) AND (T9._Period >= @P12 AND T9._Period < @P13 AND T9._Active = 0x01)
- GROUP BY T9._Fld10344RRef
- HAVING (CAST(CAST(SUM(CASE WHEN T9._RecordKind = 0.0 THEN -T9._Fld10346 ELSE T9._Fld10346 END) AS NUMERIC(27, 8)) AS NUMERIC(27, 2))) <> 0.0) T7
- GROUP BY T7.Fld10344RRef
- HAVING (CAST(SUM(T7.Fld10346Balance_) AS NUMERIC(38, 8))) <> 0.0) T6
- ON (T1._IDRRef = T6.Fld10344RRef)
- LEFT OUTER JOIN dbo._InfoRg9134 T10
- ON ((0x08 = T10._Fld9136_TYPE AND 0x000000E9 = T10._Fld9136_RTRef AND T1._IDRRef = T10._Fld9136_RRRef)) AND (T10._Fld595 = @P14)
- LEFT OUTER JOIN dbo._InfoRg11720 T11
- ON ((0x08 = T11._Fld12312_TYPE AND 0x000000E9 = T11._Fld12312_RTRef AND T1._IDRRef = T11._Fld12312_RRRef)) AND (T11._Fld595 = @P15)
- LEFT OUTER JOIN (SELECT
- T13._Fld10332_TYPE AS Fld10332_TYPE,
- T13._Fld10332_RTRef AS Fld10332_RTRef,
- T13._Fld10332_RRRef AS Fld10332_RRRef,
- CAST(SUM(T13._Fld10335) AS NUMERIC(33, 8)) AS Fld10335Balance_
- FROM dbo._AccumRgT10337 T13
- WHERE ((T13._Fld595 = @P16)) AND (T13._Period = @P17 AND (T13._Fld10335 <> @P18) AND (T13._Fld10335 <> @P19))
- GROUP BY T13._Fld10332_TYPE,
- T13._Fld10332_RTRef,
- T13._Fld10332_RRRef
- HAVING (CAST(SUM(T13._Fld10335) AS NUMERIC(33, 8))) <> 0.0) T12
- ON (0x08 = T12.Fld10332_TYPE AND 0x000000E9 = T12.Fld10332_RTRef AND T1._IDRRef = T12.Fld10332_RRRef)
- LEFT OUTER JOIN dbo._Reference51 T14
- ON (T1._Fld4635RRef = T14._IDRRef) AND (T14._Fld595 = @P20)
- WHERE ((T1._Fld595 = @P21)) AND ((T1._Fld4621RRef = @P22) AND ((CASE WHEN ((T1._Fld4657RRef = @P23) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),@P24) > @P25) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P26) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P27)) THEN @P28 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P29) = @P30) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P31) > @P32)) THEN @P33 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P34) AS NUMERIC(33, 8)) / @P35) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P36)) THEN @P37 ELSE @P38 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P39) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P40)) THEN @P41 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P42) = @P43) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P44) > @P45)) THEN @P46 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P47) AS NUMERIC(33, 8)) / @P48) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P49)) THEN @P50 ELSE @P51 END END ELSE @P52 END > @P53) OR ((CASE WHEN ((T1._Fld4657RRef = @P54) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),@P55) > @P56) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P57) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P58)) THEN @P59 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P60) = @P61) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P62) > @P63)) THEN @P64 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P65) AS NUMERIC(33, 8)) / @P66) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P67)) THEN @P68 ELSE @P69 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P70) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P71)) THEN @P72 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P73) = @P74) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P75) > @P76)) THEN @P77 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P78) AS NUMERIC(33, 8)) / @P79) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P80)) THEN @P81 ELSE @P82 END END ELSE @P83 END = @P84) AND (T1._IDRRef >= @P85))))
- ORDER BY (CASE WHEN ((T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.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)
Add Comment
Please, Sign In to add comment