﻿ SQL: Find the country where Football EURO cup 2016 held

# SQL Exercise: Find the country where Football EURO cup 2016 held

## SQL soccer Database: Joins Exercise-6 with Solution

6. From the following tables, write a SQL query to find out which country hosted the 2016 Football EURO Cup. Return country name.

Sample table: soccer_country

Sample table: soccer_city

Sample table: soccer_venue

Sample Solution:

SQL Code:

``````SELECT country_name
FROM soccer_country a
JOIN soccer_city b ON a.country_id=b.country_id
JOIN soccer_venue c ON b.city_id=c.city_id
GROUP BY country_name;
```
```

Sample Output:

``` country_name
--------------
France
(1 row)
```

Code Explanation:

The said query in SQL that selects the unique country names of all countries that have soccer venues.
The JOIN clause joins the soccer_country and soccer_city table based on the country_id column and the soccer_city and soccer_venue tables are joins based on the city_id column.
The result set are grouped by country name.

Relational Algebra Expression:

Relational Algebra Tree:

## Practice Online

Sample Database: soccer

## Query Visualization:

Duration:

Rows:

Cost:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous SQL Exercise: Find the scorer of only goal along with his country.
Next SQL Exercise: Find the player who socred first goal of EURO cup 2016.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿

Follow us on Facebook and Twitter for latest update.

## SQL: Tips of the Day

What is the best way to paginate results in SQL Server?

```SELECT  *
FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY OrderDate ) AS RowNum, *
FROM      Orders
WHERE     OrderDate >= '1980-01-01'
) AS RowConstrainedResult
WHERE   RowNum >= 1
AND RowNum < 20
ORDER BY RowNum
```

Database: SQL Server

Ref: https://bit.ly/3MGrNlk

We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook