bytecoded

Query #1

Mar 8th, 2019
309
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 25
  2. T39._IDRRef,
  3. T39._Marked,
  4. T39._Number,
  5. T39._Date_Time,
  6. T39._Posted,
  7. T39._Fld4621RRef,
  8. T39._Fld4622RRef,
  9. T39._Fld4625RRef,
  10. T39._Fld4633,
  11. T39._Fld4635RRef,
  12. T39._Fld4657RRef,
  13. CASE WHEN ((T39._Fld4657RRef = @P1) AND T39._Posted = 0x01) THEN CASE WHEN (ISNULL(CAST(T52.Fld10346Balance_ AS NUMERIC(33, 2)),0.0) > 0.0) THEN CASE WHEN (ISNULL(CAST(T40.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 4.0 WHEN ((ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T40.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T40.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 6.0 ELSE 5.0 END ELSE CASE WHEN (ISNULL(CAST(T40.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) = ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 0.0 WHEN ((ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0) = 0.0) AND (ISNULL(CAST(T40.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) > 0.0)) THEN 3.0 WHEN ((CAST(ISNULL(CAST(T40.Fld11330Turnover_ AS NUMERIC(27, 2)),0.0) AS NUMERIC(33, 8)) / 2.0) > ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) THEN 2.0 ELSE 1.0 END END ELSE 7.0 END,
  14. T57._Fld12313RRef,
  15. T39._Fld13369,
  16. CASE WHEN ((ISNULL(CAST(T58.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) > 0.0) THEN (ISNULL(CAST(T58.Fld10335Balance_ AS NUMERIC(27, 2)),0.0) + ISNULL(CAST(T42.Fld10545Balance_ AS NUMERIC(27, 2)),0.0)) ELSE 0.0 END,
  17. T68._Fld1191
  18. FROM dbo._Document233 T39
  19. LEFT OUTER JOIN (SELECT
  20. T41._Fld11328RRef AS Fld11328RRef,
  21. CAST(SUM(T41._Fld11330) AS NUMERIC(33, 8)) AS Fld11330Turnover_
  22. FROM dbo._AccumRgTn11332 T41
  23. WHERE ((T41._Fld595 = @P2)) AND ((T41._Fld11330 <> @P3))
  24. GROUP BY T41._Fld11328RRef
  25. HAVING (CAST(SUM(T41._Fld11330) AS NUMERIC(33, 8))) <> 0.0) T40
  26. ON (T39._IDRRef = T40.Fld11328RRef)
  27. LEFT OUTER JOIN (SELECT
  28. T43._Fld10540_TYPE AS Fld10540_TYPE,
  29. T43._Fld10540_RTRef AS Fld10540_RTRef,
  30. T43._Fld10540_RRRef AS Fld10540_RRRef,
  31. CAST(SUM(T43._Fld10545) AS NUMERIC(33, 8)) AS Fld10545Balance_
  32. FROM dbo._AccumRgT10549 T43
  33. WHERE (((T43._Fld595 = @P4)) AND (EXISTS(SELECT
  34. 1
  35. FROM (SELECT 1 AS SDBL_DUMMY) SDBL_DUAL
  36. LEFT OUTER JOIN dbo._Reference42 T44
  37. ON ((T43._Fld10538RRef = T44._IDRRef)) AND (T44._Fld595 = @P5)
  38. WHERE EXISTS(SELECT
  39. 0x01 AS Q_001_F_000_
  40. FROM dbo._Reference98 T45
  41. INNER JOIN dbo._Reference21 T46
  42. ON (((T45._Fld1685 = @P6) AND EXISTS(SELECT
  43. 0x01 AS Q_004_F_000_
  44. FROM dbo._InfoRg11709 T47
  45. WHERE ((T47._Fld595 = @P7)) AND ((T47._Fld12065RRef = T45._IDRRef) AND (T47._Fld12066RRef = T46._IDRRef)))) AND T46._IDRRef IN
  46. (SELECT
  47. T48._Reference21_IDRRef AS Q_005_F_000RRef
  48. FROM dbo._Reference21_VT782 T48
  49. INNER JOIN dbo._InfoRg9937 T49
  50. ON ((T49._Fld9939_TYPE = 0x08 AND T49._Fld9939_RTRef = 0x00000095 AND T49._Fld9939_RRRef = @P8) AND (T49._Fld9938_TYPE = T48._Fld784_TYPE AND T49._Fld9938_RTRef = T48._Fld784_RTRef AND T49._Fld9938_RRRef = T48._Fld784_RRRef))
  51. WHERE ((T48._Fld595 = @P9)) AND (T49._Fld595 = @P10)))
  52. WHERE ((T46._Fld595 = @P11)) AND ((CASE WHEN T44._Fld12836RRef IS NULL THEN 0x01 ELSE CASE WHEN T44._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 T50
  55. WHERE ((T50._Fld595 = @P12)) AND ((T50._Fld12072RRef = T46._IDRRef) AND (T50._Fld12073_TYPE = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x08 END AND T50._Fld12073_RTRef = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND T50._Fld12073_RRRef = T44._Fld12836RRef))) THEN 0x01 ELSE 0x00 END = CASE WHEN EXISTS(SELECT
  56. 0x01 AS Q_003_F_000_
  57. FROM dbo._InfoRg11715 T51
  58. WHERE ((T51._Fld595 = @P13)) AND ((T51._Fld12199RRef = T46._IDRRef) AND T51._Fld12200_TYPE = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x08 END AND T51._Fld12200_RTRef = CASE WHEN T44._Fld12836RRef IS NOT NULL THEN 0x0000001C END AND (T51._Fld12201 = 0x00))) THEN 0x01 ELSE 0x00 END)))))
Add Comment
Please, Sign In to add comment