When I start learning SQL I have to write a lot of nested queries when working on complex select statements from a single table. Now, I feel more comfortable with it and show how to avoid nesting. There are cases when you have to compare one row of the table with all others to get the result:
You can get rid of nesting in all above cases. Let's review the example.
- Select next element to current by the value of some field
- Select records that are unique by some complex expression
- Select all records that have the same parameter as given record.
You can get rid of nesting in all above cases. Let's review the example.