3

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 :)

Ade Mitchell
  • 43
  • 1
  • 4

1 Answers1

6

may be this:

SELECT RacerID ,  round1 + round2 + round3 + round4 - LEAST(round1, round2, round3, round4) AS Top3Rounds
FROM tablename

Fiddle example here.

Raging Bull
  • 18,593
  • 13
  • 50
  • 55
Oto Shavadze
  • 40,603
  • 55
  • 152
  • 236