Snoopy [리트코드/SQL] 26. Find Total Time Spent by Each Employee (1741)
코딩테스트/리트코드 SQL

[리트코드/SQL] 26. Find Total Time Spent by Each Employee (1741)

Sooyoon Jeong 2022. 12. 21.

🤔 문제 분석

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

 

댓글