Q:

From the following tables, write a SQL query to find those teams that scored only one goal to the tournament. Return country_name as "Team", team in the group, goal_for

0

From the following tables, write a SQL query to find those teams that scored only one goal to the tournament. Return country_name as "Team", team in the group, goal_for.

Sample table: soccer_team

team_id | team_group | match_played | won | draw | lost | goal_for | goal_agnst | goal_diff | points | group_position
---------+------------+--------------+-----+------+------+----------+------------+-----------+--------+----------------
    1201 | A          |            3 |   1 |    0 |    2 |        1 |          3 |        -2 |      3 |              3
    1202 | F          |            3 |   0 |    1 |    2 |        1 |          4 |        -3 |      1 |              4
    1203 | E          |            3 |   2 |    0 |    1 |        4 |          2 |         2 |      6 |              2
    1204 | D          |            3 |   2 |    1 |    0 |        5 |          3 |         2 |      7 |              1
    1205 | D          |            3 |   0 |    1 |    2 |        2 |          5 |        -3 |      1 |              4
    1206 | B          |            3 |   1 |    2 |    0 |        3 |          2 |         1 |      5 |              2
    1207 | A          |            3 |   2 |    1 |    0 |        4 |          1 |         3 |      7 |              1
    1208 | C          |            3 |   2 |    1 |    0 |        3 |          0 |         3 |      7 |              1
    1209 | F          |            3 |   1 |    2 |    0 |        6 |          4 |         2 |      5 |              1
    1210 | F          |            3 |   1 |    2 |    0 |        4 |          3 |         1 |      5 |              2
    1211 | E          |            3 |   2 |    0 |    1 |        3 |          1 |         2 |      6 |              1
    1212 | C          |            3 |   1 |    0 |    2 |        2 |          2 |         0 |      3 |              3
    1213 | C          |            3 |   2 |    1 |    0 |        2 |          0 |         2 |      7 |              2
    1214 | F          |            3 |   0 |    3 |    0 |        4 |          4 |         0 |      3 |              3
    1215 | E          |            3 |   1 |    1 |    1 |        2 |          4 |        -2 |      4 |              3
    1216 | A          |            3 |   0 |    1 |    2 |        2 |          4 |        -2 |      1 |              4
    1217 | B          |            3 |   0 |    1 |    2 |        2 |          6 |        -4 |      1 |              4
    1218 | B          |            3 |   1 |    1 |    1 |        3 |          3 |         0 |      4 |              3
    1219 | D          |            3 |   2 |    0 |    1 |        5 |          2 |         3 |      6 |              2
    1220 | E          |            3 |   0 |    1 |    2 |        1 |          3 |        -2 |      1 |              4
    1221 | A          |            3 |   1 |    2 |    0 |        2 |          1 |         1 |      5 |              2
    1222 | D          |            3 |   1 |    0 |    2 |        2 |          4 |        -2 |      3 |              3
    1223 | C          |            3 |   0 |    0 |    3 |        0 |          5 |        -5 |      0 |              4
    1224 | B          |            3 |   2 |    0 |    1 |        6 |          3 |         3 |      6 |              1
 country_id | country_abbr |    country_name
------------+--------------+---------------------
       1201 | ALB          | Albania
       1202 | AUT          | Austria
       1203 | BEL          | Belgium
       1204 | CRO          | Croatia
       1205 | CZE          | Czech Republic
       1206 | ENG          | England
       1207 | FRA          | France
       1208 | GER          | Germany
       1209 | HUN          | Hungary
       1210 | ISL          | Iceland
       1211 | ITA          | Italy
       1212 | NIR          | Northern Ireland
       1213 | POL          | Poland
       1214 | POR          | Portugal
       1215 | IRL          | Republic of Ireland
       1216 | ROU          | Romania
       1217 | RUS          | Russia
       1218 | SVK          | Slovakia
       1219 | ESP          | Spain
       1220 | SWE          | Sweden
       1221 | SUI          | Switzerland
       1222 | TUR          | Turkey
       1223 | UKR          | Ukraine
       1224 | WAL          | Wales
       1225 | SLO          | Slovenia
       1226 | NED          | Netherlands
       1227 | SRB          | Serbia
       1228 | SCO          | Scotland
       1229 | NOR          | Norway

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

SELECT country_name as "Team" ,team_group, goal_for
FROM soccer_team
JOIN soccer_country 
ON soccer_team.team_id=soccer_country.country_id
AND goal_for=1;

Sample Output:

  Team   | team_group | goal_for
---------+------------+----------
 Albania | A          |        1
 Austria | F          |        1
 Sweden  | E          |        1
(3 rows)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now