一个数据库语句

select tt.plate_info,

  tt.crossing_id,

  ttt.crossing_id as crossing_id2 ,

  tt.pass_time ,

  ttt.pass_time as pass_time2

from bms_vehicle_pass tt

INNER JOIN

  (select plate_info,

    pass_time,

    crossing_id

  from bms_vehicle_pass

  where

  and pass_time  <TO_DATE('2015-03-29 12:30:45', 'YYYY-MM-DD HH24:MI:SS')

  AND pass_time  >TO_DATE('2013-03-29 12:30:45', 'YYYY-MM-DD HH24:MI:SS')

  and crossing_id=2

  ) ttt

ON ttt.pass_time-30/1440< tt.pass_time

AND tt.pass_time        <ttt.pass_time

AND tt.plate_info       =ttt.plate_info

AND tt.crossing_id      =2

你可能感兴趣的:(数据库)