<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="uml.tech.bigdata.nrvpMapper.NrvpMapper">
    <select id="selectVinFromNrvp" resultType="string">
        select tv.vin
        from tb_vehicle tv
                 join
             th_terminal_change_history ttch
             on tv.id = ttch.vehicle_id
                 join tb_terminal tt
                      on tt.id = ttch.new_terminal_id
        where tt.did = #{did}
          and #{gpsTime} >= ttch.change_time
          and (ttch.end_time is null or #{gpsTime} &lt; ttch.end_time)

    </select>

</mapper>