{ "data": { "question": { "questionId": "3440", "questionFrontendId": "3126", "categoryTitle": "Database", "boundTopicId": 2758487, "title": "Server Utilization Time", "titleSlug": "server-utilization-time", "content": "
Table: Servers
\n+----------------+----------+\n| Column Name | Type |\n+----------------+----------+\n| server_id | int |\n| status_time | datetime |\n| session_status | enum |\n+----------------+----------+\n(server_id, status_time, session_status) is the primary key (combination of columns with unique values) for this table.\nsession_status is an ENUM (category) type of ('start', 'stop').\nEach row of this table contains server_id, status_time, and session_status.\n\n\n
Write a solution to find the total time when servers were running. The output should be rounded down to the nearest number of full days.
\n\nReturn the result table in any order.
\n\nThe result format is in the following example.
\n\n\n
Example:
\n\nInput:
\n\nServers table:
\n\n\n+-----------+---------------------+----------------+\n| server_id | status_time | session_status |\n+-----------+---------------------+----------------+\n| 3 | 2023-11-04 16:29:47 | start |\n| 3 | 2023-11-05 01:49:47 | stop |\n| 3 | 2023-11-25 01:37:08 | start |\n| 3 | 2023-11-25 03:50:08 | stop |\n| 1 | 2023-11-13 03:05:31 | start |\n| 1 | 2023-11-13 11:10:31 | stop |\n| 4 | 2023-11-29 15:11:17 | start |\n| 4 | 2023-11-29 15:42:17 | stop |\n| 4 | 2023-11-20 00:31:44 | start |\n| 4 | 2023-11-20 07:03:44 | stop |\n| 1 | 2023-11-20 00:27:11 | start |\n| 1 | 2023-11-20 01:41:11 | stop |\n| 3 | 2023-11-04 23:16:48 | start |\n| 3 | 2023-11-05 01:15:48 | stop |\n| 4 | 2023-11-30 15:09:18 | start |\n| 4 | 2023-11-30 20:48:18 | stop |\n| 4 | 2023-11-25 21:09:06 | start |\n| 4 | 2023-11-26 04:58:06 | stop |\n| 5 | 2023-11-16 19:42:22 | start |\n| 5 | 2023-11-16 21:08:22 | stop |\n+-----------+---------------------+----------------+\n\n\n
Output:
\n\n\n+-------------------+\n| total_uptime_days |\n+-------------------+\n| 1 |\n+-------------------+\n\n\n
Explanation:
\n\n\\u7248\\u672c\\uff1a mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\" Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\" Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\" PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\": {\"Servers\": [\"server_id\", \"status_time\", \"session_status\"]}, \"rows\": {\"Servers\": [[4, \"2023-11-29 20:22:50\", \"start\"], [4, \"2023-11-30 04:19:50\", \"stop\"], [2, \"2023-11-18 21:23:09\", \"start\"], [2, \"2023-11-19 00:38:09\", \"stop\"], [5, \"2023-11-27 18:38:16\", \"start\"], [5, \"2023-11-28 02:46:16\", \"stop\"], [4, \"2023-11-27 06:46:42\", \"start\"], [4, \"2023-11-27 08:23:42\", \"stop\"], [5, \"2023-11-11 05:09:45\", \"start\"], [5, \"2023-11-11 06:42:45\", \"stop\"], [5, \"2023-11-27 23:05:58\", \"start\"], [5, \"2023-11-27 23:48:58\", \"stop\"], [5, \"2023-11-14 16:29:34\", \"start\"], [5, \"2023-11-14 19:11:34\", \"stop\"], [1, \"2023-11-02 19:14:15\", \"start\"], [1, \"2023-11-02 20:19:15\", \"stop\"], [5, \"2023-11-03 06:55:30\", \"start\"], [5, \"2023-11-03 11:03:30\", \"stop\"], [4, \"2023-11-02 16:53:28\", \"start\"], [4, \"2023-11-02 22:28:28\", \"stop\"], [2, \"2023-11-20 07:06:41\", \"start\"], [2, \"2023-11-20 15:58:41\", \"stop\"], [1, \"2023-11-22 10:42:35\", \"start\"], [1, \"2023-11-22 19:14:35\", \"stop\"], [3, \"2023-11-23 03:05:39\", \"start\"], [3, \"2023-11-23 10:54:39\", \"stop\"], [3, \"2023-11-15 20:04:15\", \"start\"], [3, \"2023-11-15 21:30:15\", \"stop\"], [3, \"2023-11-12 08:21:42\", \"start\"], [3, \"2023-11-12 17:07:42\", \"stop\"], [1, \"2023-11-02 02:33:24\", \"start\"], [1, \"2023-11-02 12:10:24\", \"stop\"], [4, \"2023-11-14 03:55:29\", \"start\"], [4, \"2023-11-14 08:53:29\", \"stop\"], [2, \"2023-11-04 00:36:53\", \"start\"], [2, \"2023-11-04 00:37:53\", \"stop\"], [4, \"2023-11-08 01:54:18\", \"start\"], [4, \"2023-11-08 09:56:18\", \"stop\"], [1, \"2023-11-24 14:28:11\", \"start\"], [1, \"2023-11-24 21:38:11\", \"stop\"], [3, \"2023-11-20 22:55:03\", \"start\"], [3, \"2023-11-21 02:19:03\", \"stop\"], [3, \"2023-11-12 03:10:22\", \"start\"], [3, \"2023-11-12 08:29:22\", \"stop\"], [2, \"2023-11-02 14:55:46\", \"start\"], [2, \"2023-11-02 16:56:46\", \"stop\"], [1, \"2023-11-09 03:40:44\", \"start\"], [1, \"2023-11-09 03:52:44\", \"stop\"], [5, \"2023-11-16 17:43:28\", \"start\"], [5, \"2023-11-16 20:45:28\", \"stop\"], [2, \"2023-11-08 16:17:24\", \"start\"], [2, \"2023-11-09 00:59:24\", \"stop\"], [4, \"2023-11-25 04:46:06\", \"start\"], [4, \"2023-11-25 11:56:06\", \"stop\"], [2, \"2023-11-05 14:22:34\", \"start\"], [2, \"2023-11-05 21:33:34\", \"stop\"], [1, \"2023-11-02 09:49:22\", \"start\"], [1, \"2023-11-02 15:01:22\", \"stop\"], [5, \"2023-11-08 06:49:10\", \"start\"], [5, \"2023-11-08 13:33:10\", \"stop\"], [1, \"2023-11-22 21:00:23\", \"start\"], [1, \"2023-11-22 22:43:23\", \"stop\"], [3, \"2023-11-06 07:45:50\", \"start\"], [3, \"2023-11-06 15:18:50\", \"stop\"], [3, \"2023-11-02 22:13:17\", \"start\"], [3, \"2023-11-03 03:50:17\", \"stop\"], [1, \"2023-11-14 02:40:20\", \"start\"], [1, \"2023-11-14 03:57:20\", \"stop\"], [1, \"2023-11-08 21:13:00\", \"start\"], [1, \"2023-11-09 01:22:00\", \"stop\"], [5, \"2023-11-21 13:25:22\", \"start\"], [5, \"2023-11-21 19:46:22\", \"stop\"], [5, \"2023-11-16 04:37:55\", \"start\"], [5, \"2023-11-16 12:53:55\", \"stop\"], [2, \"2023-11-06 14:03:26\", \"start\"], [2, \"2023-11-06 17:11:26\", \"stop\"], [2, \"2023-11-11 08:18:54\", \"start\"], [2, \"2023-11-11 12:34:54\", \"stop\"], [2, \"2023-11-07 22:54:01\", \"start\"], [2, \"2023-11-08 08:22:01\", \"stop\"], [5, \"2023-11-23 14:08:03\", \"start\"], [5, \"2023-11-23 22:23:03\", \"stop\"], [1, \"2023-11-04 15:20:41\", \"start\"], [1, \"2023-11-04 16:09:41\", \"stop\"], [3, \"2023-11-05 01:24:32\", \"start\"], [3, \"2023-11-05 10:09:32\", \"stop\"], [4, \"2023-11-09 14:15:29\", \"start\"], [4, \"2023-11-09 18:39:29\", \"stop\"], [3, \"2023-11-28 21:43:00\", \"start\"], [3, \"2023-11-29 06:06:00\", \"stop\"], [2, \"2023-11-18 06:23:14\", \"start\"], [2, \"2023-11-18 07:34:14\", \"stop\"], [5, \"2023-11-09 17:27:02\", \"start\"], [5, \"2023-11-10 03:00:02\", \"stop\"], [2, \"2023-11-21 02:41:57\", \"start\"], [2, \"2023-11-21 07:28:57\", \"stop\"], [3, \"2023-11-08 00:36:12\", \"start\"], [3, \"2023-11-08 01:47:12\", \"stop\"], [1, \"2023-11-15 16:13:39\", \"start\"], [1, \"2023-11-15 20:29:39\", \"stop\"], [3, \"2023-11-03 06:25:01\", \"start\"], [3, \"2023-11-03 11:14:01\", \"stop\"], [1, \"2023-11-18 20:49:55\", \"start\"], [1, \"2023-11-18 23:04:55\", \"stop\"], [3, \"2023-11-13 05:02:21\", \"start\"], [3, \"2023-11-13 12:44:21\", \"stop\"], [2, \"2023-11-23 19:00:11\", \"start\"], [2, \"2023-11-24 04:59:11\", \"stop\"], [4, \"2023-11-20 01:16:38\", \"start\"], [4, \"2023-11-20 01:35:38\", \"stop\"], [1, \"2023-11-13 11:21:08\", \"start\"], [1, \"2023-11-13 11:56:08\", \"stop\"], [4, \"2023-11-21 23:09:45\", \"start\"], [4, \"2023-11-22 00:26:45\", \"stop\"], [2, \"2023-11-04 11:19:31\", \"start\"], [2, \"2023-11-04 16:46:31\", \"stop\"]]}}",
"__typename": "QuestionNode"
}
}
}MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"