I have been running the world cup database tests and all of the output is the same as in the expected output file although the team names are not in the same order. Do the team names have to be in the same order? Also I use one querie that uses two lines and im wondering if that is why it fails?
RESULTS
Total number of goals in all games from winning teams:
68
Total number of goals in all games from both teams combined:
90
Average number of goals in all games from the winning teams:
2.1250000000000000
Average number of goals in all games from the winning teams rounded to two decimal places:
2.13
Average number of goals in all games from both teams:
2.8125000000000000
Most goals scored in a single game by one team:
7
Number of games where the winning team scored more than two goals:
6
Winner of the 2018 tournament team name:
France
List of teams who played in the 2014 ‘Eighth-Final’ round:
Chile
Uruguay
Nigeria
Algeria
Mexico
Greece
Switzerland
United States
Brazil
Colombia
France
Germany
Netherlands
Costa Rica
Argentina
Belgium
List of unique winning team names in the whole data set:
Colombia
Belgium
Uruguay
England
Russia
Brazil
Argentina
Croatia
Costa Rica
Sweden
Germany
France
Netherlands
Year and team name of all the champions:
2018|France
2014|Germany
List of teams that start with ‘Co’:
Colombia
Costa Rica
queries.sh
#! /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 + 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 + 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(winner_goals) 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 FULL JOIN games ON teams.team_id = games.opponent_id WHERE year = 2014 AND round = 'Eighth-Final'")"
echo "$($PSQL "SELECT name FROM teams FULL JOIN games ON teams.team_id = games.winner_id WHERE year = 2014 AND round = 'Eighth-Final'")"
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")"
echo
echo -e "\nYear and team name of all the champions:"
echo "$($PSQL "SELECT year, name FROM teams FULL JOIN games ON teams.team_id = games.winner_id WHERE round = 'Final'")"
echo -e "\nList of teams that start with 'Co':"
echo "$($PSQL "SELECT name FROM teams FULL JOIN games ON teams.team_id = games.winner_id WHERE name LIKE 'Co%'")"