sql server - On Date base record return -
i have table structure this
vehid timefirst timelast inside 1 26/06/2014 null 0 2 26/06/2014 26/06/2014 1 2 26/06/2014 null 0 3 26/06/2014 26/06/2014 1
i want return record on base of veh enter , left on same day , pick left record of vehls.inside 0 mean veh left , 1 mean enter.expect output below
vehid timefirst timelast inside 2 26/06/2014 null 0
here, might need exclude time datetime :
select * tablename convert(date, timefirst) in ( select convert(date, timelast) tablename id = a.id) , inside = 0
Comments
Post a Comment