My first SQL query


  • 6
    Y

    select a.Id as Id
    from
    Weather as a
    join
    Weather as b
    ON
    b.Date = subdate(a.Date,1)
    where
    a.Temperature > b.Temperature;


  • 0
    M

    This is my query, I just tried to use a sub-query and it has worked, but is a little slow.

    select W.id 
    from Weather as W
    where W.Temperature > ( select W2.Temperature
    	                    from Weather as W2
                            where W.id != W2.id
                            and datediff(W.Date, W2.Date) = 1
    				      )

Log in to reply
 

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