Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select
  2. case
  3.     when (edc."attribute" ->> 'defect_root_id')::text in ('2227','2194','1850','2293','2521','2294','2258') then (odt.object_id)
  4.     else (edc."attribute" ->> 'unom')::int
  5. end as "ID объекта",
  6. case
  7.     when (edc."attribute" ->> 'defect_root_id')::text in ('2227','2194','1850','2293','2521','2294','2258') then 'ДТ'
  8.     else 'МКД'
  9. end as "Тип объекта",
  10. edc."attribute" ->> 'defect_root_id' as "ID нарушения",
  11. edc."attribute" ->> 'status_name' as "Статус",
  12. boo.system_name as "Система",
  13. (edc."attribute" ->> 'create_date')::TIMESTAMP as "Дата начала",
  14. case
  15.     when edc."attribute" ->> 'status_name' = 'Закрыта' then (edc."attribute" ->> 'start_date')::TIMESTAMP
  16.     else null
  17. end as "Дата завершения",
  18. case
  19.     when edc."attribute" ->> 'status_name' = 'Закрыта' then (FLOOR(EXTRACT(epoch FROM (edc."attribute" ->> 'start_date')::TIMESTAMP - (edc."attribute" ->> 'create_date')::TIMESTAMP)/3600))::int
  20.     else (FLOOR(EXTRACT(epoch FROM (now())::TIMESTAMP - (edc."attribute" ->> 'create_date')::TIMESTAMP)/3600))::int
  21. end AS "Дельта"
  22. from monitor_ba.edc_ba edc
  23. LEFT OUTER JOIN monitor_dict.ods_dt odt ON ((edc."attribute" ->> 'unom')::int = bti_unom),
  24. (
  25. select *
  26. from (values
  27. ('МКД', 'EDC')
  28. ) as woo (object_type, system_name)) boo
  29. where edc.create_date between '2019-03-20 00:00:00' and '2019-03-20 23:59:59'
  30. and edc.end_date = '3000-01-01 00:00:00'
  31. and edc."attribute" ->> 'status_name' not in ('Отклонена', 'Отменена')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement