php - Duration between type in and out in MYSQL -
i new mysql try here query not accurate result
select sec_to_time(sum(time_to_sec(time))) `officialbreaks` type='out' select sec_to_time(sum(time_to_sec(time))) `officialbreaks` type='in'
any buddy have work on type of situation.
out required
timediff(time type=in, time type=out) 3:35:30 time type=in, 03:35:30 time type=out output 0
you can try per below-
select distinct a.userid, (time_to_sec(b.time) - time_to_sec(a.time)) 'time_diffrence' (select userid,`time` mytable `type`='in') join (select userid,`time` mytable `type`='out') b on a.userid=b.userid
it simple solution there can multiple out time against single in time , multile users etc. there can many combination query need change.
Comments
Post a Comment