Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select site.ds_local
- ,site.vel_regulamentar as velRegulamentada
- ,sub.maiorVel
- ,sub2.dt_registro
- from site site
- ,faixa faixa
- ,registro registro
- ,(
- select site1.ds_local
- ,max(registro1.vel_aferida) as maiorVel
- from registro registro1, faixa faixa1, site site1
- where site1.id_site = faixa1.id_site
- and registro1.id_tipo_infracao= 1
- and registro1.id_faixa = faixa1.id_faixa
- and (registro1.dt_registro between '2009-11-01 00:00:00' and '2009-11-30 23:59:59')
- group by site1.ds_local
- ) sub
- ,(
- select site2.ds_local
- ,registro2.dt_registro
- ,registro2.vel_aferida
- from registro registro2, faixa faixa2, site site2
- where site2.id_site = faixa2.id_site
- and registro2.id_tipo_infracao= 1
- and registro2.id_faixa = faixa2.id_faixa
- and (registro2.dt_registro between '2009-11-01 00:00:00' and '2009-11-30 23:59:59')
- ) sub2
- where site.id_site = faixa.id_site
- and registro.id_tipo_infracao=1
- and registro.id_faixa = faixa.id_faixa
- and (registro.dt_registro between '2009-11-01 00:00:00' and '2009-11-30 23:59:59')
- and site.ds_local = sub.ds_local
- and site.ds_local = sub2.ds_local
- and sub.maiorVel = sub2.vel_aferida
- group by site.ds_local,site.vel_regulamentar, sub.maiorVel, sub2.dt_registro
- order by site.ds_local asc
Add Comment
Please, Sign In to add comment