Created
June 12, 2019 18:52
-
-
Save skarger/194629dce810b881a89efc9eedbd1ce2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT workouts.* | |
| FROM workouts JOIN ( | |
| SELECT sport_id, max(created_at) AS created_at | |
| FROM workouts | |
| GROUP BY sport_id | |
| ) latest_by_sport | |
| ON workouts.created_at = latest_by_sport.created_at | |
| AND workouts.sport_id = latest_by_sport.sport_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment