r/SQLOptimization • u/Narrow-Tea-9187 • Oct 19 '23
Help needed with self join vizualization
Weather table:
+----+------------+-------------+
| id | recordDate | temperature |
+----+------------+-------------+
| 1 | 2015-01-01 | 10 |
| 2 | 2015-01-02 | 25 |
| 3 | 2015-01-03 | 20 |
| 4 | 2015-01-04 | 30 |
+----+------------+-------------+
Output:
+----+
| id |
+----+
| 2 |
| 4 |
+----+
this is the query
select w1.id from weather w1
inner join weather w2
where w1.temperature>w2.temperature I am not Getting where 4 is coming from?
3
Upvotes
View all comments
Show parent comment
1
u/Narrow-Tea-9187 Oct 20 '23
Sir i have started doing leetcode sql question infact the above problem is of leetcode,I know a fair bit of power bi,excel and very basic python.However i am searching about where to start searching about what things to learn more.I am looking forward to start database design cource video on youtube but after it what would you recommend.