Reputation: 43
I have a table with multiple columns such as
RacerID | Round1 | Round2 | Round3 | Round4 | Total
2 100 100 96 99 395
5 99 97 100 96 392
how can i query out the top 3 results from columns (round1, round2, round3, round4) so that it should display
racerid | Top3Rounds
2 299
5 296
Many thanks :)
Upvotes: 3
Views: 109
Reputation: 42753
may be this:
SELECT RacerID , round1 + round2 + round3 + round4 - LEAST(round1, round2, round3, round4) AS Top3Rounds
FROM tablename
Fiddle example here.
Upvotes: 6