Guest User

Untitled

a guest
Jul 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. select site.ds_local
  2. ,site.vel_regulamentar as velRegulamentada
  3. ,sub.maiorVel
  4. ,sub2.dt_registro
  5.  
  6. from site site
  7. ,faixa faixa
  8. ,registro registro
  9. ,(
  10. select site1.ds_local
  11. ,max(registro1.vel_aferida) as maiorVel
  12. from registro registro1, faixa faixa1, site site1
  13. where site1.id_site = faixa1.id_site
  14. and registro1.id_tipo_infracao= 1
  15. and registro1.id_faixa = faixa1.id_faixa
  16. and (registro1.dt_registro between '2009-11-01 00:00:00' and '2009-11-30 23:59:59')
  17. group by site1.ds_local
  18. ) sub
  19. ,(
  20. select site2.ds_local
  21. ,registro2.dt_registro
  22. ,registro2.vel_aferida
  23. from registro registro2, faixa faixa2, site site2
  24. where site2.id_site = faixa2.id_site
  25. and registro2.id_tipo_infracao= 1
  26. and registro2.id_faixa = faixa2.id_faixa
  27. and (registro2.dt_registro between '2009-11-01 00:00:00' and '2009-11-30 23:59:59')
  28. ) sub2
  29.  
  30.  
  31. where site.id_site = faixa.id_site
  32. and registro.id_tipo_infracao=1
  33. and registro.id_faixa = faixa.id_faixa
  34. and (registro.dt_registro between '2009-11-01 00:00:00' and '2009-11-30 23:59:59')
  35. and site.ds_local = sub.ds_local
  36. and site.ds_local = sub2.ds_local
  37. and sub.maiorVel = sub2.vel_aferida
  38.  
  39. group by site.ds_local,site.vel_regulamentar, sub.maiorVel, sub2.dt_registro
  40. order by site.ds_local asc
Add Comment
Please, Sign In to add comment