10000 Update 1661_Average_Time_of_Process_per_Machine.sql · rajtuts/raj-leetcode-sql-50@d851587 · GitHub
[go: up one dir, main page]

Skip to content

Commit d851587

Browse files
authored
Update 1661_Average_Time_of_Process_per_Machine.sql
1 parent e9cc1c6 commit d851587

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

2-Basic-Joins/1661_Average_Time_of_Process_per_Machine.sql

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,39 @@
2727

2828
-- Return the result table in any order.
2929

30-
Example 1:
30+
-- Example 1:
3131

32-
Input:
33-
Activity table:
34-
+------------+------------+---------------+-----------+
35-
| machine_id | process_id | activity_type | timestamp |
36-
+------------+------------+---------------+-----------+
37-
| 0 | 0 | start | 0.712 |
38-
| 0 | 0 | end | 1.520 |
39-
| 0 | 1 | start | 3.140 |
40-
| 0 | 1 | end | 4.120 |
41-
| 1 | 0 | start | 0.550 |
42-
| 1 | 0 | end | 1.550 |
43-
| 1 | 1 | start | 0.430 |
44-
| 1 | 1 | end | 1.420 |
45-
| 2 | 0 | start | 4.100 |
46-
| 2 | 0 | end | 4.512 |
47-
| 2 | 1 | start | 2.500 |
48-
| 2 | 1 | end | 5.000 |
49-
+------------+------------+---------------+-----------+
50-
Output:
51-
+------------+-----------------+
52-
| machine_id | processing_time |
53-
+------------+-----------------+
54-
| 0 | 0.894 |
55-
| 1 | 0.995 |
56-
| 2 | 1.456 |
57-
+------------+-----------------+
58-
Explanation:
59-
There are 3 machines running 2 processes each.
60-
Machine 0's average time is ((1.520 - 0.712) + (4.120 - 3.140)) / 2 = 0.894
61-
Machine 1's average time is ((1.550 - 0.550) + (1.420 - 0.430)) / 2 = 0.995
62-
Machine 2's average time is ((4.512 - 4.100) + (5.000 - 2.500)) / 2 = 1.456
32+
-- Input:
33+
-- Activity table:
34+
-- +------------+------------+---------------+-----------+
35+
-- | machine_id | process_id | activity_type | timestamp |
36+
-- +------------+------------+---------------+-----------+
37+
-- | 0 | 0 | start | 0.712 |
38+
-- | 0 | 0 | end | 1.520 |
39+
-- | 0 | 1 | start | 3.140 |
40+
-- | 0 | 1 | end | 4.120 |
41+
-- | 1 | 0 | start | 0.550 |
42+
-- | 1 | 0 | end | 1.550 |
43+
-- | 1 | 1 | start | 0.430 |
44+
-- | 1 | 1 | end | 1.420 |
45+
-- | 2 | 0 | start | 4.100 |
46+
-- | 2 | 0 | end | 4.512 |
47+
-- | 2 | 1 | start | 2.500 |
48+
-- | 2 | 1 | end | 5.000 |
49+
-- +------------+------------+---------------+-----------+
50+
-- Output:
51+
-- +------------+-----------------+
52+
-- | machine_id | processing_time |
53+
-- +------------+-----------------+
54+
-- | 0 | 0.894 |
55+
-- | 1 | 0.995 |
56+
-- | 2 | 1.456 |
57+
-- +------------+-----------------+
58+
-- Explanation:
59+
-- There are 3 machines running 2 processes each.
60+
-- Machine 0's average time is ((1.520 - 0.712) + (4.120 - 3.140)) / 2 = 0.894
61+
-- Machine 1's average time is ((1.550 - 0.550) + (1.420 - 0.430)) / 2 = 0.995
62+
-- Machine 2's average time is ((4.512 - 4.100) + (5.000 - 2.500)) / 2 = 1.456
6363

6464

6565
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)
0