php - Duration between type in and out in MYSQL -


enter image description here

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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -