Why using a condition on Id not working?


  • 3
    C
    SELECT a.Id FROM Weather a INNER JOIN Weather b ON a.Id=b.Id+1
     WHERE a.Temperature>b.Temperature
    

    I know the logic here is all about one day earlier, but the code I write should have given the same answer. However, it was not working here. Why?


  • 0
    S

    because it is not a must tuples are arranged in date order, you can judge from the input of error case


  • 0
    C

    Thanks for your reply. It's true that they are in date order, but it doesn't necessarily mean that they are not in id oder. Since they are also in id oder, why it is not working? Is it because we cannot directly plus 1 to the variable 'id'?


  • 0
    K

    Check this test case:

    {"headers": {"Weather": ["Id"
    "Date"
    "Temperature"]}
    "rows": {"Weather": [[1
    "2000-12-16"
    3]
    [2
    "2000-12-15"
    -1]]}}
    

  • 0
    S

    @czhfrank Have you figured out the reason?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.