Leetcode 197. Rising temperature

Source: Internet
Author: User
Tags mysql query
197. Rising temperatureQuestion Editorial Solution submissions total accepted:18016 total submissions:68688 difficulty:easy

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

+---------+------------+------------------+
| Id (INT) | Date (date) | Temperature (INT) |
+---------+------------+------------------+
|       1 | 2015-01-01 |               Ten |
|       2 | 2015-01-02 |               |
|       3 | 2015-01-03 |               |
|       4 | 2015-01-04 |               |
+---------+------------+------------------+
For example, return the following Ids for the above Weather table:
+----+
| Id |
+----+
|  2 |
|  4 |
+----+

Subscribe to the which companies asked this question

Have you met this question in a real interview? Yes

# Write your MySQL query statement below
Select W1. Id from Weather W1, Weather W2 where W1. Temperature>w2. Temperature and To_days (W1. Date)-to_days (W2. Date) = 1;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.