Some thing wrong with my world cup database queries

After I build my World Cup Database, I found that my output is the same as the given output for checking. But the coderoad does not give me a pass.

My code so far

echo -e "\nTotal number of goals in all games from winning teams:"
echo "$($PSQL "SELECT SUM(winner_goals) FROM games")"

echo -e "\nTotal number of goals in all games from both teams combined:"
echo "$($PSQL "select sum(winner_goals)+sum(opponent_goals) from games")"

echo -e "\nAverage number of goals in all games from the winning teams:"
echo "$($PSQL "select avg(winner_goals) from games")"

echo -e "\nAverage number of goals in all games from the winning teams rounded to two decimal places:"
echo "$($PSQL "select round(avg(winner_goals),2) from games")"

echo -e "\nAverage number of goals in all games from both teams:"
echo "$($PSQL "select (avg(winner_goals)+avg(opponent_goals)) from games")"

echo -e "\nMost goals scored in a single game by one team:"
echo "$($PSQL "select max(winner_goals) from games")"

echo -e "\nNumber of games where the winning team scored more than two goals:"
echo "$($PSQL "select count(*) from games where winner_goals>2")"

echo -e "\nWinner of the 2018 tournament team name:"
echo "$($PSQL "select name from teams full join games on teams.team_id=games.winner_id where year=2018 and round='Final'")"

echo -e "\nList of teams who played in the 2014 'Eighth-Final' round:"
echo "$($PSQL "select name from teams inner join games on teams.team_id=games.winner_id or teams.team_id=games.opponent_id where year=2014 and round='Eighth-Final' order by name")"

echo -e "\nList of unique winning team names in the whole data set:"
echo "$($PSQL "select distinct(name) from games left join teams on teams.team_id=games.winner_id order by name")"

echo -e "\nYear and team name of all the champions:"
echo "$($PSQL "select year, name from games left join teams on teams.team_id=games.winner_id where round='Final' order by year")"

echo -e "\nList of teams that start with 'Co':"
echo "$($PSQL "select name from teams where name like 'Co%' order by name")"

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36

Challenge: Build a World Cup Database

Link to the challenge:

Which tests are not passing for you?

Hi, I had the same problem.

For me it was the number of zeros in one of the answers. I fixed with:

echo -e “\nAverage number of goals in all games from both teams:”
echo “$($PSQL “SELECT AVG(winner_goals + opponent_goals) FROM games”)”

I hope this helps.

1 Like

Please open a new topic on the forum with the ask for help button so that the thread can be used to discuss the issues with you. This thread belongs to another user and is from the past April. We ask everyone not to post to someone else’s thread if they cannot offer help or if they are not asking a follow up question to them or to a previous response. (Also in your own thread you will be allowed to mark a specific response as a solution which you cannot perform here).