--- /dev/null
+#include "fetch_max_score_for_song.h"
+
+FetchMaxScoreForSong::FetchMaxScoreForSong(unsigned tournament, unsigned song, unsigned *score)
+ : tournament(tournament), song(song), score(score) {}
+
+void FetchMaxScoreForSong::operator() (pqxx::transaction<> &t)
+{
+ pqxx::result res( t.exec("SELECT MAX(feetrating)*1000 AS max_score FROM songratings WHERE song=" +
+ pqxx::to_string(song) + " AND machine=( SELECT machine FROM tournaments WHERE tournament=" +
+ pqxx::to_string(tournament) + ")") );
+
+ *score = res.at(0)["max_score"].as(*score);
+}