https://hackershare.dev/bookmarks/747820
Query the row with the greatest/least value per group