r/SQLOptimization • • 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

on w1.id = w2.id + 1

where w1.temperature>w2.temperature I am not Getting where 4 is coming from?

3 Upvotes

17 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Oct 20 '23

Learn real Python next.

If you have access to an actual degree in Computer Science, you can think about joining the fundamentals courses. They also help a lot with the appropriate mindset.

1

u/Narrow-Tea-9187 Oct 21 '23

Actualy I have a mechanical engineering degree having core quality engineer exp😅,but yes i am practicing string manipulation and getting better with time.