SQL Exercise: Find the number of venues for EURO cup 2016
1. From the following table, write a SQL query to count the number of venues for EURO cup 2016. Return number of venues.
Sample table: soccer_venuevenue_id | venue_name | city_id | aud_capacity ----------+-------------------------+---------+-------------- 20001 | Stade de Bordeaux | 10003 | 42115 20002 | Stade Bollaert-Delelis | 10004 | 38223 20003 | Stade Pierre Mauroy | 10005 | 49822 20004 | Stade de Lyon | 10006 | 58585 20005 | Stade VElodrome | 10007 | 64354 20006 | Stade de Nice | 10008 | 35624 20007 | Parc des Princes | 10001 | 47294 20008 | Stade de France | 10002 | 80100 20009 | Stade Geoffroy Guichard | 10009 | 42000 20010 | Stadium de Toulouse | 10010 | 33150
Sample Solution:
-- This SQL query calculates the total number of rows in the 'soccer_venue' table.
SELECT COUNT(*)
-- COUNT(*) is an aggregate function that counts the number of rows in a result set.
FROM soccer_venue;
-- 'soccer_venue' is the name of the table from which the count is being calculated.
Sample Output:
count ------- 10 (1 row)
Code Explanation:
The said query in SQL that counts the total number of rows in the soccer_venue table. The COUNT(*) function is an aggregate function that counts the number of rows returned by a query. The result of the query will be a single value, which represents the total number of rows in the soccer_venue table.
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: SQL Basic Exercises on Soccer Database
Next SQL Exercise: Number of countries participated in the EURO cup 2016.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics