SQLSQL
#17

Compare Sequential Daily Records with Self-Join in SQL

MediumGoogle
Interview Question #17
Asked at Google

Given a `weather` table with `id`, `record_date`, and `temperature`, write a SQL query to find all record IDs where the temperature was higher than the previous day's (yesterday's) temperature.

Input Table: weather
4 rows preview
idrecord_datetemperature
12026-01-0110
22026-01-0225
32026-01-0320
42026-01-0430
Expected Output Structure2 rows
id
2
4
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us