Synopsis: Ambiguous Groups

Let's learn how using ambiguous groups causes an antipattern.

Suppose that your boss needs to know which projects in the bugs database are still active and which projects have been abandoned. One report they ask you to generate is the latest bug reported per product. You write a query using the MySQL database to calculate the greatest value in the date_reported column per group of bugs sharing a given product_id. The report looks like this:

product_name latest bug_id
Open RoundFile 2010-06-01 1234
Visual TurboBuilder 2010-02-16 3456
ReConsider 2010-01-01 5678

Your boss is detail-oriented, and they spend some time looking up each bug listed in the report. They notice that the row listed ...