World Cup Database - Build a World Cup Database

Tell us what’s happening:
Hello! I’ve filled in my queries.sh file and I’ve checked that he output is identical to the file expected_output.txt but when I hit the Run button, it says that I still need to complete queries.sh correcty. Can anyone help?

Your code so far

#! /bin/bash

PSQL="psql --username=freecodecamp --dbname=worldcup --no-align --tuples-only -c"

# Do not change code above this line. Use the PSQL variable above to query your database.

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 DISTINCT COUNT(winner_id) FROM games WHERE winner_goals > 2")"

echo -e "\nWinner of the 2018 tournament team name:"

echo "$($PSQL "SELECT name FROM teams INNER 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 DISTINCT name FROM games INNER JOIN teams ON games.winner_id=teams.team_id OR games.opponent_id=teams.team_id WHERE year=2014 AND round='Eighth-Final' ORDER BY name ASC;")"

echo -e "\nList of unique winning team names in the whole data set:"

echo "$($PSQL "SELECT DISTINCT name FROM teams INNER JOIN games ON teams.team_id=games.winner_id ORDER BY name ASC")"

echo -e "\nYear and team name of all the champions:"

echo "$($PSQL "SELECT year, name FROM teams INNER JOIN games ON teams.team_id=games.winner_id WHERE round='Final' ORDER BY year ASC")"

echo -e "\nList of teams that start with 'Co':"

echo "$($PSQL "SELECT name FROM teams INNER JOIN games ON teams.team_id=games.winner_id WHERE name LIKE 'Co%'")"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: World Cup Database - Build a World Cup Database

Link to the challenge:

Please pipe the result of the script into a file then use the diff command to compare your output to the expected one. Even one space or extra new line can change the results.

1 Like

Thank you!!! I didn’t realise I had too many decimals on the third line!

1 Like