SQL Challenges-1: Rising Sulfur Dioxide
From the following table, write a SQL query to find all dates' city ID with higher pollution compared to its previous dates (yesterday). Return city ID, date and pollution.
Input:
Table: so2_pollution
Structure:
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
city_id | int(11) | YES | |||
date | date | YES | |||
so2_amt | int(11) | YES |
Data:
city_id | date | so2_amt |
---|---|---|
701 | 2015-10-15 | 5 |
702 | 2015-10-16 | 7 |
703 | 2015-10-17 | 9 |
704 | 2018-10-18 | 15 |
105 | 2015-10-19 | 14 |
Sample Solution:
SQL Code:
Sample Output:
City ID| -------| 702| 703|
Solution-1:
SQL Code Editor:
Contribute your code and comments through Disqus.
Previous: Remove Duplicate Emails.
Next: Highest Sale Amount.