Example 1
Find the coldest and hottest recorded temperatures
Chicago (15) is the coldest and Miami (32) is the hottest. Both functions scan all rows and return a single aggregate value. Add GROUP BY city to find the min and max per city instead of across the whole table.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE temperatures (id INT, city VARCHAR(50), temp INT);
INSERT INTO
temperatures (id, city, temp)
VALUES
(1, 'NYC', 22),
(2, 'LA', 28),
(3, 'Chicago', 15),
(4, 'Miami', 32);Validated query Shared across supported engines.
SQL
SELECT
MIN(temp) AS min_temp,
MAX(temp) AS max_temp
FROM
temperatures;Expected result Returned rows for the shared example.
| min_temp | max_temp |
|---|---|
| 15 | 32 |
Output is identical across all engines.