-
1741. Find Total Time Spent by Each Employee mysqlLeetCode_Study_Plan/SQL 2022. 10. 2. 15:13
https://leetcode.com/problems/find-total-time-spent-by-each-employee/?envType=study-plan&id=sql-i
Find Total Time Spent by Each Employee - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
select tb.event_day as day, tb.emp_id as emp_id, sum(diff_time) as total_time from (select event_day, emp_id, out_time - in_time as diff_time from employees) tb group by 1, 2;
속도가 넘 후지길래.. 다른 예시 답안도 좀 찾아봤더니
그냥 서브쿼리 없이 해도 되었다.
ㅎ_ㅎ
아래는 예시코드이다.
SELECT event_day AS day, emp_id, SUM(out_time - in_time) AS total_time FROM Employees GROUP BY event_day, emp_id;
출처 : https://github.com/everthis/leetcode-js/blob/master/1741-find-total-time-spent-by-each-employee.sql
'LeetCode_Study_Plan > SQL' 카테고리의 다른 글
1393. Capital Gain/Loss mysql (0) 2022.10.03 1407. Top Travellers mysql (0) 2022.10.03 1890. The Latest Login in 2020 mysql (0) 2022.10.02 511. Game Play Analysis I mysql (0) 2022.10.02 586. Customer Placing the Largest Number of Orders mysql (0) 2022.10.02