Alex
Alex

Reputation: 1

Newbie; Running Rankings database

I have 2 tables. One with results and one with athletes. When I run it lists every result from every athlete. How do I just get the fastest time from each athlete? In the example below I just want Reed Brown fastest time.

id  place   athlete_id  grade   team_id             time    event
126 3      Reed Brown   11      TEXAS               4:01.99 1600m
127 1      Reed Brown   11      Southlake Carroll   4:07.17 1600m
95  1      Reed Brown   11      Southlake Carroll   4:07.17 1600m
128 2      Bryce Hoppel 12      Midland Senior      4:15.12 1600m
96  2      Bryce Hoppel 12      Midland Senior H    4:15.12 1600m

Upvotes: 0

Views: 48

Answers (1)

arias_JC
arias_JC

Reputation: 559

Try the following:

Select per.*
From performances per
Inner Join
(
  Select athlete_id, MIN(time) AS fastesttime 
  From performances 
  Group By athlete_id
)per1
On per1.athlete_id=per.athlete_id
Where per1.fastesttime=per.time

Upvotes: 2

Related Questions