Exercise #16 (tips and solutions)
The redundancy of the solution 1.12.2 can be eliminated by removing the subquery completely and performing the join between the tables P and L. This way, the query will not just become shorter, but also easy to read and, which is no less important, more efficient.
Here is another example of a query difficult to read; this solution would be correct if the model column was numeric:
However, the data type VARCHAR(50) implies the presence of arbitrary characters, which is the case for the checking database (say, model T-64). For such data, the type conversion operation
To me, this seems like a good example of how not to write queries. But how to write them? Have a look at the exercise forum after solving it to find the best examples.
Return to discussion of exercise #16