Server Fleet Uptime
Amazon 🧠 Hard SQL
Beginner Mode

Objective

Amazon Web Services (AWS) is powered by fleets of servers. Senior management has requested data-driven solutions to optimize server usage. You are given a table that logs each server's start and stop events.

Table Schema:

The server_utilization table:

Column Type Description
server_id integer ID of the server
status_time timestamp Timestamp of the event
session_status text Either 'start' or 'stop'

Task Requirements:

  • Calculate the total time that the fleet of servers was running
  • Each server might start and stop several times
  • The total fleet running time is the sum of each server's uptime across all sessions
  • Output the result in units of full days (truncate any partial day)



Output columns: total_uptime_days

Examples

Example 1:

Input:

server_utilization
server_idsession_statusstatus_time
1start2025-01-01 08:00:00
1stop2025-01-03 16:00:00
2start2025-01-02 10:00:00
2stop2025-01-04 10:00:00

Output:
total_uptime_days
4
Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →