bytecoded

Query #4

Mar 8th, 2019
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.96 KB | None | 0 0
  1. )SELECT TOP 45
  2. T7._IDRRef,
  3. T7._Marked,
  4. T7._Number,
  5. T7._Date_Time,
  6. T7._Posted,
  7. T7._Fld4621RRef,
  8. T7._Fld4622RRef,
  9. T7._Fld4625RRef,
  10. T7._Fld4633,
  11. T7._Fld4635RRef,
  12. T7._Fld4657RRef,
  13. CASE WHEN ((T7._Fld4657RRef = @P1) AND T7._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T20.Fld10346Balance_ AS NUMERIC(33, 2)),0.0) > 0.0) THEN CASE WHEN (ISNULL(CAST(T8.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 4.0 WHEN ((ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T8.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T8.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 6.0 ELSE 5.0 END ELSE CASE WHEN (ISNULL(CAST(T8.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 0.0 WHEN ((ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T8.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T8.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 2.0 ELSE 1.0 END END ELSE 7.0 END,
  14. T25._Fld12313RRef,
  15. T7._Fld13369,
  16. CASE WHEN ((ISNULL(CAST(T26.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) > 0.0) THEN (ISNULL(CAST(T26.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T10.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) ELSE 0.0 END,
  17. T36._Fld1191
  18. FROM dbo._Document233 T7
  19. LEFT OUTER JOIN (SELECT
  20. T9._Fld11328RRef AS Fld11328RRef,
  21. CAST(SUM(T9._Fld11330) AS NUMERIC(33, 8)) AS Fld11330Turnover_
  22. FROM dbo._AccumRgTn11332 T9
  23. WHERE ((T9._Fld595 = @P2)) AND ((T9._Fld11330 <> @P3))
  24. GROUP BY T9._Fld11328RRef
  25. HAVING (CAST(SUM(T9._Fld11330) AS NUMERIC(33, 8))) <> 0.0) T8
  26. ON (T7._IDRRef = T8.Fld11328RRef)
  27. LEFT OUTER JOIN (SELECT
  28. T11._Fld10540_TYPE AS Fld10540_TYPE,
  29. T11._Fld10540_RTRef AS Fld10540_RTRef,
  30. T11._Fld10540_RRRef AS Fld10540_RRRef,
  31. CAST(SUM(T11._Fld10545) AS NUMERIC(33, 8)) AS Fld10545Balance_
  32. FROM dbo._AccumRgT10549 T11
  33. WHERE (((T11._Fld595 = @P4)) AND (EXISTS(SELECT
  34. 1
  35. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  36. LEFT OUTER JOIN dbo._Reference42 T12
  37. ON ((T11._Fld10538RRef = T12._IDRRef)) AND (T12._Fld595 = @P5)
  38. WHERE EXISTS(SELECT
  39. 0x01 AS Q_001_F_000_
  40. FROM dbo._Reference98 T13
  41. INNER JOIN dbo._Reference21 T14
  42. ON (((T13._Fld1685 = @P6) AND EXISTS(SELECT
  43. 0x01 AS Q_004_F_000_
  44. FROM dbo._InfoRg11709 T15
  45. WHERE ((T15._Fld595 = @P7)) AND ((T15._Fld12065RRef = T13._IDRRef) AND (T15._Fld12066RRef = T14._IDRRef)))) AND T14._IDRRef IN
  46. (SELECT
  47. T16._Reference21_IDRRef AS Q_005_F_000RRef
  48. FROM dbo._Reference21_VT782 T16
  49. INNER JOIN dbo._InfoRg9937 T17
  50. ON ((T17._Fld9939_TYPE = 0x08 AND T17._Fld9939_RTRef = 0x00000095 AND T17._Fld9939_RRRef = @P8) AND (T17._Fld9938_TYPE = T16._Fld784_TYPE AND T17._Fld9938_RTRef = T16._Fld784_RTRef AND T17._Fld9938_RRRef = T16._Fld784_RRRef))
  51. WHERE ((T16._Fld595 = @P9)) AND (T17._Fld595 = @P10)))
  52. WHERE ((T14._Fld595 = @P11)) AND ((CASE WHEN T12._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T12._Fld12836RRef IS NOT NULL THEN 0x08 END END <> 0x01) AND (CASE WHEN EXISTS(SELECT
  53. 0x01 AS Q_002_F_000_
  54. FROM dbo._InfoRg11710 T18
  55. WHERE ((T18._Fld595 = @P12)) AND ((T18._Fld12072RRef = T14._IDRRef) AND (T18._Fld12073_TYPE = CASE WHEN T12._Fld12836RRef IS NOT NULL THEN 0x08 END AND T18._Fld12073_RTRef = CASE WHEN T12._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T18._Fld12073_RRRef = T12._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  56. 0x01 AS Q_003_F_000_
  57. FROM dbo._InfoRg11715 T19
  58. WHERE ((T19._Fld595 = @P13)) AND ((T19._Fld12199RRef = T14._IDRRef) AND T19._Fld12200_TYPE = CASE WHEN T12._Fld12836RRef IS NOT NULL THEN 0x08 END AND T19._Fld12200_RTRef = CASE WHEN T12._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T19._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))) AND (T11._Period = @P14 AND (
Add Comment
Please, Sign In to add comment