leetcode原文引用:

Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.

+---------+------------+------------------+
| Id(INT) | Date(DATE) | Temperature(INT) |
+---------+------------+------------------+
|       1 | 2015-01-01 |               10 |
|       2 | 2015-01-02 |               25 |
|       3 | 2015-01-03 |               20 |
|       4 | 2015-01-04 |               30 |
+---------+------------+------------------+
For example, return the following Ids for the above Weather table:
+----+
| Id |
+----+
|  2 |
|  4 |
+----+
我的sql语句如下:

select t2.id from Weather t1 
inner join Weather t2 on 
t1.Temperature < t2.temperature
and 
to_days(t1.Date) = to_days(t2.Date)-1

注意:原来忘了使用to_days函数,导致提交一直说有错误,必须要加上to_days函数!!

相关文章:

  • 2021-10-11
  • 2022-01-09
  • 2022-02-22
  • 2022-12-23
  • 2021-06-12
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-05
  • 2021-08-28
  • 2021-05-29
  • 2021-11-30
  • 2021-12-13
  • 2022-12-23
  • 2021-10-29
相关资源
相似解决方案