Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- case
- when (edc."attribute" ->> 'defect_root_id')::text in ('2227','2194','1850','2293','2521','2294','2258') then (odt.object_id)
- else (edc."attribute" ->> 'unom')::int
- end as "ID объекта",
- case
- when (edc."attribute" ->> 'defect_root_id')::text in ('2227','2194','1850','2293','2521','2294','2258') then 'ДТ'
- else 'МКД'
- end as "Тип объекта",
- edc."attribute" ->> 'defect_root_id' as "ID нарушения",
- edc."attribute" ->> 'status_name' as "Статус",
- boo.system_name as "Система",
- (edc."attribute" ->> 'create_date')::TIMESTAMP as "Дата начала",
- case
- when edc."attribute" ->> 'status_name' = 'Закрыта' then (edc."attribute" ->> 'start_date')::TIMESTAMP
- else null
- end as "Дата завершения",
- case
- when edc."attribute" ->> 'status_name' = 'Закрыта' then (FLOOR(EXTRACT(epoch FROM (edc."attribute" ->> 'start_date')::TIMESTAMP - (edc."attribute" ->> 'create_date')::TIMESTAMP)/3600))::int
- else (FLOOR(EXTRACT(epoch FROM (now())::TIMESTAMP - (edc."attribute" ->> 'create_date')::TIMESTAMP)/3600))::int
- end AS "Дельта"
- from monitor_ba.edc_ba edc
- LEFT OUTER JOIN monitor_dict.ods_dt odt ON ((edc."attribute" ->> 'unom')::int = bti_unom),
- (
- select *
- from (values
- ('МКД', 'EDC')
- ) as woo (object_type, system_name)) boo
- where edc.create_date between '2019-03-20 00:00:00' and '2019-03-20 23:59:59'
- and edc.end_date = '3000-01-01 00:00:00'
- and edc."attribute" ->> 'status_name' not in ('Отклонена', 'Отменена')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement