#! /usr/bin/perl

use ccbs;
use strict;
use warnings;

my $cgi = new CGI;
my $id = $cgi->param('id');

my $dbh = ccbs::db_connect();

my $players = ccbs::db_fetch_all($dbh, 'SELECT player,nick,countryname,clubname,count(*) AS num_songs,COUNT(DISTINCT song) AS num_unique_songs,COUNT(DISTINCT tournament) AS num_tournaments,AVG(score)::integer AS avg_score,MAX(score) AS high_score FROM scores NATURAL JOIN players NATURAL JOIN countries NATURAL LEFT JOIN clubs GROUP BY player,nick,countryname,clubname ORDER BY LOWER(nick)');

ccbs::print_header();
ccbs::process_template('players.tmpl', 'Spillere', {
	players => $players,
});
$dbh->disconnect;
