如何找出使用Mysql的员工工作的小时数

时间:2014-09-09 10:38:33

标签: mysql

我在mysql中有一个名为logindetails的表和另一个logoutdetails

的表

logindetails ---->列名为login_time

logoutdetails ---->列名为logout_time

我想知道用户从login_timelogout_time工作的小时数,请让我知道我是这个领域的新手:

SELECT e.Employee_Name, SUM(hours) 
FROM logindetails e 
INNER JOIN logoutdetails a ON e.Login_Time = a.Logout_Time 
GROUP BY e.Employee_Name

2 个答案:

答案 0 :(得分:0)

尝试这样的事情:

SELECT e.Employee_Name, HOUR(TIMEDIFF(e.Login_Time,a.Logout_Time) )
FROM logindetails e 
INNER JOIN logoutdetails a ON e.Employee_Name = a.Employee_Name
GROUP BY e.Employee_Name

答案 1 :(得分:0)

SELECT e.Employee_Name, 
       TIMESTAMPDIFF(hour,e.Login_Time, a.Logout_Time)  
FROM   logindetails e 
INNER JOIN logoutdetails a ON e.Empolyee_Name = a.Employee_Name 
GROUP BY e.Employee_Name