Stuck on Build a World Cup Database challenge

I am currently stuck on the building a world cup database challenge. In the last task it says

You should correctly complete the queries in the queries.sh file. Fill in each empty echo command to get the output of what is suggested with the command above it. Only use a single line like the first query. The output should match what is in the example_output.txt file

So, I checked my output of the queries.sh file which is the exact match of the expected_output.txt file. But still can’t pass the tests.
Please tell me what seems to be the problem.
here is my output in the terminal.


image

here is the expected_output.text file

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:
Algeria
Argentina
Belgium
Brazil
Chile
Colombia
Costa Rica
France
Germany
Greece
Mexico
Netherlands
Nigeria
Switzerland
United States
Uruguay

List of unique winning team names in the whole data set:
Argentina
Belgium
Brazil
Colombia
Costa Rica
Croatia
England
France
Germany
Netherlands
Russia
Sweden
Uruguay

Year and team name of all the champions:
2014|Germany
2018|France

List of teams that start with 'Co':
Colombia
Costa Rica

Currently, the output needs to match the example_output exactly, space for space. Your lists of teams are all on one line - they need to be a list, each team on their own line. I can look into changing that so it isn’t so strict - but for now, that’s what it expects.

1 Like

I changed it. Now I have passed it. Thanks.

1 Like

codeally@61581fc85910:~/project$ ./queries.sh

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.81250000000000000000

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:
Algeria
Argentina
Belgium
Brazil
Chile
Colombia
Costa Rica
France
Germany
Greece
Mexico
Netherlands
Nigeria
Switzerland
United States
Uruguay

List of unique winning team names in the whole data set:
Argentina
Belgium
Brazil
Colombia
Costa Rica
Croatia
England
France
Germany
Netherlands
Russia
Sweden
Uruguay

Year and team name of all the champions:
2014|Germany
2018|France

List of teams that start with ‘Co’:
Colombia
Costa Rica
codeally@61581fc85910:~/project$

See, my outputs are exactly the same as the file, and yet the platform is not accepting the solution.

Your “Average number of goals in all games from both teams” has too many zero’s @ky-JP

1 Like

lol, thanks a lot my friend. I didn’t realize, sry

1 Like

I don’t know what’s wrong. The results are good.

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 games RIGHT JOIN teams ON games.winner_id=teams.team_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 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")"

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

echo "$($PSQL "SELECT DISTINCT(name) FROM teams FULL JOIN games ON teams.team_id=games.winner_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 (winner_id IS NOT NULL AND round='Final') GROUP BY year, name")"

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

echo $($PSQL "SELECT name FROM teams WHERE name LIKE 'Co%'")"

Can you share the results of running the script @mettabhavana? It needs to match the example exactly - sometimes the order is off in one of the queries or maybe one of them has some extra zeros in a decimal or something.

List of teams that start with ‘Co’:
./queries.sh line 43: unexpected EOF while lloking for matching ` "
./queries.sh line 44: syntax error: unexpected end of file

I changed the last question to:

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

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 name LIKE ‘Co%’ ORDER BY name”)"

The rest is correct.

It’s giving you a syntax error. It says line 43 and 44 - I’m not sure if that’s the line you are sharing, but it looks like there might be an extra quote at the end of that line of code: ORDER BY name”)" ← that last quote doesn’t have a matching quote.

Thanks! I had missed that one too. :grin: