High Resource Usage Customers
Problem statement
Identify every customer with at least one site_data log where memory utilization, disk utilization, or CPU utilization is strictly greater than 50%.
For each qualifying customer, calculate averages across all of that customer's logs:
average_memory_usage: average of100 * memory_used_gb / memory_allocated_gb.average_disk_storage: average of100 * disk_used_gb / disk_allocated_gb.average_cpu_utilization: average ofcpu_utilization_percent.
Round every average to two decimal places. Return rows ordered by customer_name ascending, then customer_id ascending.
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
customers
Customer identities.
| Column | Type | Nullable | Description |
|---|---|---|---|
| customer_idPK | Integer | No | — |
| customer_name | Text | No | — |
site_data
Resource-usage logs for monitored customer sites.
| Column | Type | Nullable | Description |
|---|---|---|---|
| log_idPK | Integer | No | — |
| customer_id | Integer | No | — |
| memory_used_gb | Decimal | No | — |
| memory_allocated_gb | Decimal | No | — |
| disk_used_gb | Decimal | No | — |
| disk_allocated_gb | Decimal | No | — |
| cpu_utilization_percent | Decimal | No | — |
Foreign key: customer_id → customers(customer_id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| customer_name | Text | No | — |
| average_memory_usage | Decimal | No | — |
| average_disk_storage | Decimal | No | — |
| average_cpu_utilization | Decimal | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
customers.customer_idandsite_data.log_idare unique primary keys.- Every
site_data.customer_idreferences an existing customer. memory_allocated_gbanddisk_allocated_gbare positive.- Usage and allocation values are nonnegative decimals, and CPU utilization is between 0 and 100.
- A customer may have multiple logs; averages include every log after the customer qualifies.