We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给定一个 Weather 表,编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 Id。
Weather
+---------+------------------+------------------+ | Id(INT) | RecordDate(DATE) | Temperature(INT) | +---------+------------------+------------------+ | 1 | 2015-01-01 | 10 | | 2 | 2015-01-02 | 25 | | 3 | 2015-01-03 | 20 | | 4 | 2015-01-04 | 30 | +---------+------------------+------------------+
例如,根据上述给定的 Weather 表格,返回如下 Id:
+----+ | Id | +----+ | 2 | | 4 | +----+
mysql
题目不是很难,就是有一个函数需要了解一下,TO_DAYS 给定一个日期 date,返回一个天数(年份从0开始的天数)。第一次直接拿两个值进行比较,挂了一次。和日期有关的值,记得使用 TO_DAYS。
TO_DAYS
select b.Id from Weather a inner join Weather b on TO_DAYS(a.RecordDate) = TO_DAYS(b.RecordDate) - 1 where b.Temperature > a.Temperature
The text was updated successfully, but these errors were encountered:
No branches or pull requests
给定一个
Weather
表,编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 Id。例如,根据上述给定的
Weather
表格,返回如下 Id:mysql
题目不是很难,就是有一个函数需要了解一下,
TO_DAYS
给定一个日期 date,返回一个天数(年份从0开始的天数)。第一次直接拿两个值进行比较,挂了一次。和日期有关的值,记得使用 TO_DAYS。The text was updated successfully, but these errors were encountered: