我在mysql中有一个名为logindetails
的表和另一个logoutdetails
logindetails
---->列名为login_time
logoutdetails
---->列名为logout_time
我想知道用户从login_time
到logout_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
答案 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