Advertisement
Dadilton

Tempo médio de tramitação por ano

Nov 18th, 2020
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select 'Tempo médio de tramitação (em dias)' "Item",
  2.        avg(case when vp.dta_abertura < '31/12/2018 23:59:59.999'::timestamp
  3.                  and (vp.dta_ultima_baixa is null or vp.dta_ultima_baixa between '01/01/2018'::timestamp and '31/12/2018 23:59:59.999'::timestamp) then
  4.            extract(day from coalesce(vp.dta_ultima_baixa,'31/12/2018 23:59:59.999'::timestamp) - vp.dta_abertura) end)::numeric(10,2)  "Ano 2018",
  5.        avg(case when vp.dta_abertura < '31/12/2019 23:59:59.999'::timestamp
  6.                  and (vp.dta_ultima_baixa is null or vp.dta_ultima_baixa between '01/01/2019'::timestamp and '31/12/2019 23:59:59.999'::timestamp) then
  7.            extract(day from coalesce(vp.dta_ultima_baixa,'31/12/2019 23:59:59.999'::timestamp) - vp.dta_abertura) end)::numeric(10,2)  "Ano 2019",
  8.        avg(case when vp.dta_abertura < '31/12/2020 23:59:59.999'::timestamp
  9.                  and (vp.dta_ultima_baixa is null or vp.dta_ultima_baixa between '01/01/2020'::timestamp and '31/12/2020 23:59:59.999'::timestamp) then
  10.            extract(day from coalesce(vp.dta_ultima_baixa,'31/12/2020 23:59:59.999'::timestamp) - vp.dta_abertura) end)::numeric(10,2)  "Ano 2020"
  11. from taxa_congestionamento.vm_processo vp
  12. where vp.int_vara_id_rh = 181 -- id da vara que vc (Nírondes) tá usando
  13.   and vp.int_comarca_id_rh = 118 -- comarca de são luís
  14.   and (vp.dta_ultima_baixa is null or dta_ultima_baixa > '01/01/2018'::timestamp) -- pegando apenas os processos que estavam tramitando no ano de 2018 prá cima
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement