Query X rows with the greatest/least value per group, i.e. do the SQL LIMIT, but per group. This complex problem is more general variant of [tag:greatest-n-per-group].
Query X rows with the greatest/least value per group, i.e. do the SQL LIMIT, but per group. This complex problem is more general variant of greatest-n-per-group.