World Cup Database - Build a World Cup Database

Tell us what’s happening:

Good day, I am having difficulty in passing the last test on the worldcup database project, the result of my query.sh is the same with the expected_output.txt. Any idea what might be wrong. Here is my gitpod snapshot for the project, Dashboard
Thank you.

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”)”

the above command is showing some question mark

echo -e “\nMost goals scored in a single game by one team:”

echo “$($PSQL “SELECT GREATEST(MAX(winner_goals), MAX(opponent_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 games FULL JOIN teams ON games.winner_id = teams.team_id WHERE round=‘Final’ AND year=2018”)”

echo -e “\nList of teams who played in the 2014 ‘Eighth-Final’ round:”

echo “$($PSQL “SELECT teams.name FROM games INNER JOIN teams ON games.winner_id = teams.team_id INNER JOIN teams a ON games.opponent_id = a.team_id WHERE year=2014 AND round=‘Eighth-Final’ UNION SELECT a.name FROM games INNER JOIN teams ON games.winner_id = teams.team_id INNER JOIN teams a ON games.opponent_id = a.team_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 FULL JOIN teams ON games.winner_id = teams.team_id WHERE winner_id IS NOT NULL ORDER BY name”)”

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

echo “$($PSQL “SELECT year, name FROM games FULL JOIN teams ON games.winner_id = teams.team_id WHERE round=‘Final’ ORDER BY year”)”

echo -e “\nList of teams that start with ‘Co’:”

echo “$($PSQL “SELECT name FROM teams WHERE name ILIKE ‘Co%’”)”

Your browser information:

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

Challenge Information:

World Cup Database - Build a World Cup Database

Hi @sirvinlex

How many decimal places are in the expected output?

Happy coding

hi, thanks for the reply, the expected output has 16 decimal places, so is my own result. I event use JS length property to compare them, they have the same length

I think you need to make the SELECT command specify the number of decimal places.

Hi, thanks for your help, it appears one of my query doesn’t have the same decimal point with expected output. I have fixed that and successfully passed the test

1 Like