Guest User

Untitled

a guest
Feb 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. select ex.gsm,
  2. ex.motivo_envio,
  3. ex.status,
  4. ex.data_ativacao,
  5. ex.data_importacao,
  6. ex.data_alteracao
  7. from export ex
  8. where ex.status = 'ANOMALIA TEMPORÁRIA'
  9. and exists (
  10. select tmp.gsm
  11. from export tmp
  12. where tmp.gsm = ex.gsm
  13. and tmp.motivo_envio = ex.motivo_envio
  14. and tmp.status = ex.status
  15. group by tmp.gsm, tmp.motivo_envio, tmp.status
  16. having count(tmp.gsm) > 1)
  17. and data_alteracao = (select max(data_alteracao) from export tmp
  18. where tmp.gsm = ex.gsm
  19. and tmp.motivo_envio = ex.motivo_envio
  20. and tmp.status = ex.status
  21. group by tmp.gsm, tmp.motivo_envio, tmp.status
  22. having count(tmp.gsm) > 1)
Add Comment
Please, Sign In to add comment