Within-group aggregates with another wrinkle.
Recently when optimising an SQL query I needed to return a specific subset of records from a large table. The brilliant Common Queries Tree pointed me in the right direction, but the examples didn’t quite cover my specific case. I needed the records with the maximal value of x and the minimal value of y … Read more