8 my $id = $cgi->param('id');
10 my $dbh = ccbs::db_connect();
12 my $songs = ccbs::db_fetch_all($dbh, 'SELECT machine,machinename,song,title,artist,avg_score,stddev_score,high_score,high_score_player,high_score_nick FROM machinesongs NATURAL JOIN songs NATURAL JOIN machines NATURAL LEFT JOIN ( SELECT song,AVG(score)::integer AS avg_score,STDDEV(score)::integer AS stddev_score FROM scores JOIN tournaments ON scores.tournament=tournaments.tournament WHERE scoringsystem=1 GROUP BY song ) t1 NATURAL LEFT JOIN ( SELECT DISTINCT ON (song) song,player AS high_score_player,nick AS high_score_nick,score AS high_score FROM scores NATURAL JOIN players JOIN tournaments ON scores.tournament=tournaments.tournament WHERE scoringsystem=1 ORDER BY song,score DESC ) t2 ORDER BY machine,LOWER(title)');
15 ccbs::process_template('songs.tmpl', 'Sanger', {