This quiz is based on an email I got from a somewhat annoyed Jesper Krogh.
btw, I’m still looking for new entries. I get quite a few suggestions, but not all of them make it into quiz questions. Do send in your suggestions!
Given:
SELECT * FROM car_parts: +---------+---------+-------+--------+ | part_id | car_id | price | weight | +---------+---------+-------+--------+ | 1 | 1 | 2.20 | 3.00 | | 2 | 1 | 3.30 | 5.00 | | 3 | 1 | 4.40 | 7.00 | | 4 | 2 | 2.20 | 9.00 | | 5 | 2 | 3.30 | 11.00 | | 6 | 2 | 4.40 | 13.00 | +---------+---------+-------+--------+
We want to know the least expensive part of each car, and how much that part weighs:
SELECT car_id, MIN(price), weight FROM parts GROUP BY car_id; +---------+------------+--------+ | car_id | MIN(price) | weight | …[Read more]