Exercise #13 |
||
Find out the average speed of the PCs produced by maker A. Solution 1.10.1. A common mistake of beginners is, attempting to use freshly learned language constructs regardless of whether they are suitable for the task or not. Below is a typical example:
Here, the subquery in the WHERE clause gets the processor speed values for PCs produced by maker A. Then, the average speed is calculated for all PCs whose processor speeds match any values in the list returned by said subquery. As a result, processor speeds of PCs by, say, maker B will be included in the calculation if they happen to be equal to any speed values for maker A. The computation will be done correctly only if the set of PC processor speeds for maker A doesn’t intersect with corresponding sets for other manufacturers. |