🤔 문제 분석
1) Write an SQL query to calculate the total time in minutes spent by each employee on each day at the office.
2) Note that within one day, an employee can enter and leave more than once.
3) The time spent in the office for a single entry is out_time - in_time.
💡 풀이
SELECT event_day AS day, emp_id, sum(out_time - in_time) AS total_time
FROM Employees
GROUP BY day, emp_id
'코딩테스트 > 리트코드 SQL' 카테고리의 다른 글
[리트코드/SQL] 28. Top Travellers (1407) (0) | 2022.12.23 |
---|---|
[리트코드/SQL] 27. Capital Gain/Loss(1393) (0) | 2022.12.21 |
[리트코드/SQL] 25. The Latest Login in 2020 (1890) (0) | 2022.12.18 |
[리트코드/SQL] 24. Game Play Analysis I (511) (0) | 2022.12.18 |
[리트코드/SQL] 23. Customer Placing the Largest Number of Orders (586) (0) | 2022.12.18 |
댓글