Advertisement
Guest User

PRF008 com cidade

a guest
May 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. SELECT DISTINCT
  2. v.nivel
  3. ,COALESCE(v.filial, 'NÃO IDENTIFICADO') filial
  4. ,pf.registro_nacional rnp
  5. ,v.registro_regional
  6. ,pf.nome
  7. ,pf.cpf
  8. ,pf.sexo
  9. ,to_char(pf.data_nascimento,'DD/MM/YYYY') data_nascimento
  10. ,p.email
  11. ,trim(coalesce(e.tipologradouro, '') || ' ' || coalesce(e.logradouro, '') || ' ' || coalesce(e.numero, '') || ' - ' || coalesce(e.bairro, '') ||' - ' || coalesce(e.complemento, '') || ' - ' || coalesce(e.cidade, '') || '/' || coalesce(e.uf, '') || ' - ' || coalesce(e.cep, '')) AS endereco
  12. ,trim (coalesce(e.cidade, ''))AS cidade
  13. ,'('||e.ddd||') '||e.telefone as telefone
  14. ,v.ultimoexercicioquitado
  15. ,v.ultimoexerciciopago
  16. ,(select x.parcela||'/'||x.qtdparcelas from (select max(a.parcela) as parcela, qtdparcelas from tb_anuidade as a where a.pessoa_id = v.pessoa_id and v.ultimoexerciciopago = a.exercicio group by qtdparcelas limit 1) as x) as ultimaparcelapaga
  17. ,v.titulos
  18. , tr.descricao ||': '||v.situacao_registro as "registro/situacao"
  19. , to_char(v.data_ini_registro,'DD/MM/YYYY') data_inicio_registro
  20. , to_char(v.data_situacao_registro,'DD/MM/YYYY') data_situacao_registro
  21. FROM relatorios.tb_profissional_report v
  22. INNER JOIN tb_profissional pf ON pf.pessoa_id = v.pessoa_id
  23. INNER JOIN tb_pessoa p ON p.id = v.pessoa_id
  24. LEFT JOIN tb_enderecos e ON e.id = p.enderecocorrespondencia
  25. LEFT JOIN tb_tiporegistro tr ON tr.codigo = v.tipo_registro
  26. LEFT JOIN tb_situacaoregistro sr ON sr.descricao = v.situacao_registro
  27. LEFT JOIN tb_profissional_titulo pt ON pt.pessoa_id = v.pessoa_id AND pt.ativo IS TRUE WHERE v.ultimoexerciciopago BETWEEN 2016 AND 2017
  28. ORDER BY pf.nome
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement