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 varbinary(16),@P22 NUMERIC(10),@P23 NUMERIC(10),@P24 varbinary(16),@P25 varbinary(16),@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 NUMERIC(10),@P55 NUMERIC(10),@P56 varbinary(16),@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 NUMERIC(10),@P86 NUMERIC(10),@P87 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,
- CASE WHEN (T1._Fld4657RRef = 0xAEB7F7D9237C245A447AADE98F164CDF) THEN CASE WHEN T1._Posted = 0x01 THEN CASE WHEN T1._Fld14039 = 0x01 THEN CASE WHEN (ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) <= 0.0) THEN 0.0 WHEN ((CAST(ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) AS NUMERIC(26, 8)) / ISNULL(CAST(T14.Fld14035Receipt_ AS NUMERIC(21, 3)),0.0)) <= 0.5) THEN 1.0 WHEN ((CAST(ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) AS NUMERIC(26, 8)) / ISNULL(CAST(T14.Fld14035Receipt_ AS NUMERIC(21, 3)),0.0)) < 1.0) THEN 2.0 WHEN ((CAST(ISNULL(CAST(T14.Fld14035Expense_ AS NUMERIC(21, 3)),0.0) AS NUMERIC(26, 8)) / ISNULL(CAST(T14.Fld14035Receipt_ AS NUMERIC(21, 3)),0.0)) >= 1.0) THEN 3.0 END ELSE 3.0 END ELSE 0.0 END ELSE 7.0 END,
- T16._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 (SELECT
- T15._Fld14033RRef AS Fld14033RRef,
- CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN T15._Fld14035 ELSE 0.0 END) AS NUMERIC(26, 8)) AS Fld14035Receipt_,
- CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN 0.0 ELSE T15._Fld14035 END) AS NUMERIC(26, 8)) AS Fld14035Expense_
- FROM dbo._AccumRg14026 T15
- WHERE ((T15._Fld595 = @P20)) AND (T15._Active = 0x01 AND ((T15._Fld14031RRef = @P21)))
- GROUP BY T15._Fld14033RRef
- HAVING (CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN T15._Fld14035 ELSE 0.0 END) AS NUMERIC(26, 8))) <> 0.0 OR (CAST(SUM(CASE WHEN T15._RecordKind = 0.0 THEN 0.0 ELSE T15._Fld14035 END) AS NUMERIC(26, 8))) <> 0.0) T14
- ON (T14.Fld14033RRef = T1._IDRRef)
- LEFT OUTER JOIN dbo._Reference51 T16
- ON (T1._Fld4635RRef = T16._IDRRef) AND (T16._Fld595 = @P22)
- WHERE ((T1._Fld595 = @P23)) AND ((T1._Fld4621RRef = @P24) AND ((CASE WHEN ((T1._Fld4657RRef = @P25) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),@P26) > @P27) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P28) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P29)) THEN @P30 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P31) = @P32) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P33) > @P34)) THEN @P35 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P36) AS NUMERIC(33, 8)) / @P37) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P38)) THEN @P39 ELSE @P40 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P41) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P42)) THEN @P43 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P44) = @P45) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P46) > @P47)) THEN @P48 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P49) AS NUMERIC(33, 8)) / @P50) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P51)) THEN @P52 ELSE @P53 END END ELSE @P54 END < @P55) OR ((CASE WHEN ((T1._Fld4657RRef = @P56) AND T1._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T6.Fld10346Balance_ AS NUMERIC(33, 2)),@P57) > @P58) THEN CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P59) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P60)) THEN @P61 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P62) = @P63) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P64) > @P65)) THEN @P66 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P67) AS NUMERIC(33, 8)) / @P68) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P69)) THEN @P70 ELSE @P71 END ELSE CASE WHEN (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P72) = ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P73)) THEN @P74 WHEN ((ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P75) = @P76) AND (ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P77) > @P78)) THEN @P79 WHEN ((CAST(ISNULL(CAST(T2.Fld11330Turnover_ AS NUMERIC(27, 2)),@P80) AS NUMERIC(33, 8)) / @P81) > ISNULL(CAST(T4.Fld10545Balance_ AS NUMERIC(27, 2)),@P82)) THEN @P83 ELSE @P84 END END ELSE @P85 END = @P86) AND (T1._IDRRef < @P87))))
- 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) DESC, (T1._IDRRef) DESC
Add Comment
Please, Sign In to add comment