Processos No Departamento select distinct p58_codproc, p58_dtproc, p58_requer, p58_codigo, z01_nome, p58_numero::integer, p58_ano, p51_descr, p61_id_usuario, p68_codproc, p61_codandam, p61_codproc, p61_coddepto, p78_codandam, p87_codandam, p86_codandam, p53_codigo, (select a.p53_coddepto from andpadrao a where a.p53_codigo = protprocesso.p58_codigo and a.p53_ordem = (andpadrao.p53_ordem + 1) limit 1 ) as proxdepto, (select b.descrdepto from andpadrao a inner join db_depart b on b.coddepto = a.p53_coddepto where a.p53_codigo = protprocesso.p58_codigo and a.p53_ordem = (andpadrao.p53_ordem + 1) limit 1 ) as proxdescr from protprocesso inner join cgm on z01_numcgm = p58_numcgm inner join tipoproc on p51_codigo = p58_codigo and p51_tipoprocgrupo = 1 inner join procandam on p61_codandam = p58_codandam left join andpadrao on p53_codigo = p58_codigo and p53_coddepto = p61_coddepto and p53_ordem = (select count(*) from procandam pa where pa.p61_codproc = p58_codproc) left join arqproc on p68_codproc = protprocesso.p58_codproc inner join procandamint on p78_codandam = p58_codandam left join proctransferintand on p87_codandam = p78_codandam left join procandamintand on p86_codandam = p78_codandam and p86_codtrans = p87_codtransferint where p61_coddepto = 17 and p68_codproc is null and (select p63_codtran from proctransferproc inner join proctransand on p64_codtran = p63_codtran where p63_codproc = p58_codproc limit 1 ) is not null and not exists ( select * from processosapensados where p30_procapensado = p58_codproc limit 1) order by p58_codproc desc
Autor: Marcio de Andrade Mendes
88 comentários
Atenciosamente, Douglas Nunes
Comercial
douglas@dbseller.com.br
DBSeller Informática Ltda. - www.dbseller.com.br
(51) 30765101