Problem Β· Database
Get Average Thermostat Temperature π‘
Problem statement
The devices table contains temperature devices installed in
rooms. Return the average thermostat temperature for each room that has
more than two thermostat rows.
Round each average to the nearest whole number and return the rows in
descending order by room_name.
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.
devices
Temperature-related devices installed in rooms.
| Column | Type | Nullable | Description |
|---|---|---|---|
| room_name | Text | No | Room containing the device. |
| device_type | Text | No | Device classification. |
| temperature | Decimal | No | Temperature reported by the device. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| room_name | Text | No | β |
| average_temperature | Decimal | No | β |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- Only rows whose
device_typeis exactlyThermostatcount. - A room with exactly two thermostats is not included.
- If an average is exactly halfway between two integers, round away from zero.
- Return the columns as
room_nameandaverage_temperature.