Skip to content

Commit 483d259

Browse files
committed
task: #1741
1 parent 81f6fb0 commit 483d259

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Have a good contributing!
5151
- [1407. Top Travellers](./leetcode/easy/1407.%20Top%20Travellers.sql)
5252
- [1484. Group Sold Products By The Date](./leetcode/easy/1484.%20Group%20Sold%20Products%20By%20The%20Date.sql)
5353
- [1729. Find Followers Count](./leetcode/easy/1729.%20Find%20Followers%20Count.sql)
54+
- [1741. Find Total Time Spent by Each Employee](./leetcode/easy/1741.%20Find%20Total%20Time%20Spent%20by%20Each%20Employee.sql)
5455
2. [Medium](./leetcode/medium/)
5556
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
5657
- [184. Department Highest Salary](./leetcode/medium/184.%20Department%20Highest%20Salary.sql)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Question 1741. Find Total Time Spent by Each Employee
3+
Link: https://leetcode.com/problems/find-total-time-spent-by-each-employee/description/
4+
5+
Table: Employees
6+
7+
+-------------+------+
8+
| Column Name | Type |
9+
+-------------+------+
10+
| emp_id | int |
11+
| event_day | date |
12+
| in_time | int |
13+
| out_time | int |
14+
+-------------+------+
15+
(emp_id, event_day, in_time) is the primary key (combinations of columns with unique values) of this table.
16+
The table shows the employees' entries and exits in an office.
17+
event_day is the day at which this event happened, in_time is the minute at which the employee entered the office, and out_time is the minute at which they left the office.
18+
in_time and out_time are between 1 and 1440.
19+
It is guaranteed that no two events on the same day intersect in time, and in_time < out_time.
20+
21+
22+
Write a solution to calculate the total time in minutes spent by each employee on each day at the office. Note that within one day, an employee can enter and leave more than once. The time spent in the office for a single entry is out_time - in_time.
23+
24+
Return the result table in any order.
25+
*/
26+
27+
SELECT
28+
event_day AS day, --noqa: RF04
29+
emp_id,
30+
SUM(out_time - in_time) AS total_time
31+
FROM Employees
32+
GROUP BY event_day, emp_id

0 commit comments

Comments
 (0)