Complete the code to select all records from the historical data table.
SELECT * FROM [1];The table historical_data stores past records. Using SELECT * FROM historical_data; retrieves all historical records.
Complete the code to filter historical data for sensor ID 101.
SELECT * FROM historical_data WHERE sensor_id = [1];The sensor ID is a number, so it should be used without quotes in the query.
Fix the error in the query to get data between two dates.
SELECT * FROM historical_data WHERE timestamp [1] '2024-01-01' AND timestamp [2] '2024-01-31';
To get data from January 1st to January 31st, use >= '2024-01-01' for the start date and <= '2024-01-31' for the end date.
Fill both blanks to query average temperature for sensor 202 in February 2024.
SELECT AVG([1]) FROM historical_data WHERE sensor_id = 202 AND timestamp [2] '2024-02-01' AND timestamp <= '2024-02-28';
The query calculates the average temperature for sensor 202 starting from February 1st (using >= for the date).
Fill all three blanks to get max pressure for sensor 303 between March 1 and March 15, 2024.
SELECT MAX([1]) FROM historical_data WHERE sensor_id = [2] AND timestamp >= '[3]' AND timestamp <= '2024-03-15';
This query finds the maximum pressure for sensor 303 from March 1st (2024-03-01) to March 15th, 2024.