题目描述
Given a Weather
table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates.
1 | +---------+------------------+------------------+ |
For example, return the following Ids for the above Weather
table:
1 | +----+ |
考查date_sub的用法,date_sub(date, interval k day)为找到date的前k天并返回。
date可用curdate()表示今天。
代码实现
1 | select s.id from weather as s, weather as t |