Attempting to learn SQL, coming from a Python background.
How does SQL compare entries?
I’m used to having a variable store something, compare it to a new one, keep the old variable or store the new information as the old variable, continuing over a loop. I’ve noticed with SQL, looping isn’t something you do a lot.
For example, here’s my query from a problem on LeetCode.
recordData is a date
All other column names are int
SELECT
w1.id as id
FROM
Weather as w1,
Weather as w2
WHERE
DATEDIFF(w1.recordDate, w2.recordDate) = 1
AND w1.temperature > w2.temperature
Would WHERE take the first w1.recordDate and compare to each w2.recordDate starting with the first then work down each w1.recordDate in this fashion?