Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- )INSERT INTO tt1 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_005, _Q_000_F_006, _Q_000_F_007) SELECT
- T1.Fld11293_TYPE,
- T1.Fld11293_RTRef,
- T1.Fld11293_RRRef,
- T1.Fld11295RRef,
- (T1.Fld11302Turnover_ - T1.Fld11303Turnover_),
- T70.IDRRef,
- CASE WHEN CASE WHEN T1.Fld11290_TYPE = 0x08 AND T1.Fld11290_RTRef = 0x00000058 THEN T83._Fld12837 ELSE CAST(NULL AS BINARY(1)) END = 0x01 THEN (T1.Fld11302Turnover_ - T1.Fld11303Turnover_) ELSE 0.0 END,
- CASE WHEN (NOT ((CASE WHEN T1.Fld11290_TYPE = 0x08 AND T1.Fld11290_RTRef = 0x00000058 THEN T83._Fld12837 ELSE CAST(NULL AS BINARY(1)) END) = 0x01)) THEN (T1.Fld11302Turnover_ - T1.Fld11303Turnover_) ELSE 0.0 END,
- CAST(0.0 AS NUMERIC(21, 2)),
- CAST(NULL AS NUMERIC(21, 2))
- FROM (SELECT
- T2._Fld11290_TYPE AS Fld11290_TYPE,
- T2._Fld11290_RTRef AS Fld11290_RTRef,
- T2._Fld11290_RRRef AS Fld11290_RRRef,
- T2._Fld11295RRef AS Fld11295RRef,
- T2._Fld11293_TYPE AS Fld11293_TYPE,
- T2._Fld11293_RTRef AS Fld11293_RTRef,
- T2._Fld11293_RRRef AS Fld11293_RRRef,
- CAST(SUM(T2._Fld11303) AS NUMERIC(33, 8)) AS Fld11303Turnover_,
- CAST(SUM(T2._Fld11302) AS NUMERIC(33, 8)) AS Fld11302Turnover_
- FROM dbo._AccumRgTn11305 T2
- WHERE (((T2._Fld595 = @P1)) AND (EXISTS(SELECT
- 1
- FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
- LEFT OUTER JOIN dbo._Document233 T3
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000E9 AND T2._Fld11293_RRRef = T3._IDRRef) AND (T3._Fld595 = @P2)
- LEFT OUTER JOIN dbo._Document212 T4
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D4 AND T2._Fld11293_RRRef = T4._IDRRef) AND (T4._Fld595 = @P3)
- LEFT OUTER JOIN dbo._Document234 T5
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000EA AND T2._Fld11293_RRRef = T5._IDRRef) AND (T5._Fld595 = @P4)
- LEFT OUTER JOIN dbo._Document263 T6
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x00000107 AND T2._Fld11293_RRRef = T6._IDRRef) AND (T6._Fld595 = @P5)
- LEFT OUTER JOIN dbo._Document216 T7
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D8 AND T2._Fld11293_RRRef = T7._IDRRef) AND (T7._Fld595 = @P6)
- LEFT OUTER JOIN dbo._Document215 T8
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D7 AND T2._Fld11293_RRRef = T8._IDRRef) AND (T8._Fld595 = @P7)
- LEFT OUTER JOIN dbo._Document213 T9
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000D5 AND T2._Fld11293_RRRef = T9._IDRRef) AND (T9._Fld595 = @P8)
- LEFT OUTER JOIN dbo._Document199 T10
- ON (T2._Fld11293_TYPE = 0x08 AND T2._Fld11293_RTRef = 0x000000C7 AND T2._Fld11293_RRRef = T10._IDRRef) AND (T10._Fld595 = @P9)
- LEFT OUTER JOIN dbo._Reference42 T11
- 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 = @P10)
- WHERE EXISTS(SELECT
- 0x01 AS Q_001_F_000_
- FROM dbo._Reference98 T12
- INNER JOIN dbo._Reference21 T13
- ON (((T12._Fld1685 = @P11) AND EXISTS(SELECT
- 0x01 AS Q_008_F_000_
- FROM dbo._InfoRg11709 T14
- WHERE ((T14._Fld595 = @P12)) AND ((T14._Fld12065RRef = T12._IDRRef) AND (T14._Fld12066RRef = T13._IDRRef)))) AND T13._IDRRef IN
- (SELECT
- T15._Reference21_IDRRef AS Q_009_F_000RRef
- FROM dbo._Reference21_VT782 T15
- INNER JOIN dbo._InfoRg9937 T16
- ON ((T16._Fld9939_TYPE = 0x08 AND T16._Fld9939_RTRef = 0x00000095 AND T16._Fld9939_RRRef = @P13) AND (T16._Fld9938_TYPE = T15._Fld7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement