mess9

Untitled

Jun 24th, 2021
1,627
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.     FLDEXTERNALNUMBER AS VSP_NUMBER,
  3.     FLDORGANIZATIONUNID AS CLIENT_ID,
  4.     LOCALSYSTEMID AS ORDER_ID,
  5.     FLDORDERNUMBER AS ORDER_NUMBER,
  6.     FLDWFSTATUS AS ORDER_STATUS,
  7.     PERSISTDATE AS ORDER_DATE
  8. FROM
  9.     esb.ORDERCMS
  10. WHERE 1=1
  11.     AND VERSION = 0
  12.     AND DELETED = 0
  13.     AND FLDORDERNUMBER IS NOT NULL
  14.     AND FLDWFSTATUS IN ('Услуга эксплуатируется', 'Тестирование услуги', 'Выполняется отключение', 'Экстренное включение', 'Приемка клиентом')
  15.     AND FLDORGANIZATIONUNID IS NOT NULL
  16.     AND LOCALSYSTEMID IS NOT NULL
  17.     AND ENDDATE > CURRENT_TIMESTAMP
  18.     AND FLDEXTERNALNUMBER =
  19.     (
  20.     SELECT
  21.         FLDEXTERNALNUMBER
  22.     FROM
  23.         (
  24.         SELECT
  25.             FLDEXTERNALNUMBER,
  26.             COUNT(*)
  27.         FROM
  28.             ESB.ORDERCMS sample (0.1) o
  29.         WHERE 1=1
  30.             AND VERSION = 0
  31.             AND DELETED = 0
  32.             AND FLDORDERNUMBER IS NOT NULL
  33.             AND FLDEXTERNALNUMBER IS NOT NULL
  34.             AND FLDEXTERNALNUMBER != '0000-00000'
  35.             AND FLDWFSTATUS IN ('Услуга эксплуатируется', 'Тестирование услуги', 'Выполняется отключение', 'Экстренное включение', 'Приемка клиентом')
  36.             AND FLDORGANIZATIONUNID IS NOT NULL
  37.             AND LOCALSYSTEMID IS NOT NULL
  38.             AND ENDDATE < CURRENT_TIMESTAMP
  39.             AND rownum <= 1
  40.         GROUP BY FLDEXTERNALNUMBER
  41.         HAVING COUNT(*) < 2
  42.         )
  43.     )
  44. ORDER BY PERSISTDATE DESC
  45. FETCH FIRST 1 ROWS ONLY
RAW Paste Data