File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
8000
27
27
28
28
-- Return the result table in any order.
29
29
30
+ Example 1 :
31
+
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
63
+
64
+
30
65
------------------------------------------------------------------------------
31
66
32
67
-- SQL Schema
You can’t perform that action at this time.
0 commit comments