Difference between revisions of "SUM and COUNT Quiz"
From SQLZOO
| Line 46: | Line 46: | ||
{Select the statement that shows the sum of population of all countries in 'Europe' | {Select the statement that shows the sum of population of all countries in 'Europe' | ||
|type="()"} | |type="()"} | ||
| − | - | + | - SELECT name, population FROM bbc WHERE region = 'Europe' |
| − | - | + | - SELECT population FROM bbc WHERE region = 'Europe' SUM BY region |
| − | + | + | + SELECT SUM(population) FROM bbc WHERE region = 'Europe' |
| − | - | + | - SELECT SUM(population FROM bbc WHERE region = 'Europe') |
| − | - | + | - SUM population FROM bbc WHERE region = 'Europe' |
{Select the statement that shows the number of countries with population smaller than 150000 | {Select the statement that shows the number of countries with population smaller than 150000 | ||
|type="()"} | |type="()"} | ||
| − | + | + | + SELECT COUNT(name) FROM bbc WHERE population < 150000 |
| − | - | + | - SELECT COUNT(population < 150000) FROM bbc |
| − | - | + | - SELECT name FROM bbc WHERE population < 150000 |
| − | - | + | - SELECT population AS COUNT FROM bbc WHERE population < 150000 |
| − | - | + | - SELECT SUM() FROM bbc WHERE population < 150000 |
{Select the full set of SQL aggregate functions | {Select the full set of SQL aggregate functions | ||
|type="()"} | |type="()"} | ||
| − | - | + | - AVG(), COUNT(), FIRST(), LAST(), SUM() |
| − | - | + | - AVG(), COUNT(), MAX(), MEDIAN(), MIN(), ROUND(), SUM() |
| − | + | + | + AVG(), COUNT(), FIRST(), LAST(), MAX(), MIN(), SUM() |
| − | - | + | - AVG(), COUNT(), MAX(), MIN(), SUM() |
| − | - | + | - COUNT(), SUM() |
{Select the statement that shows the average population of 'Poland', 'Germany' and 'Denmark' | {Select the statement that shows the average population of 'Poland', 'Germany' and 'Denmark' | ||
Revision as of 15:34, 6 August 2012
SUM and COUNT QUIZ
| name | region | area | population | gdp |
|---|---|---|---|---|
| Afghanistan | South Asia | 652225 | 26000000 | |
| Albania | Europe | 28728 | 3200000 | 6656000000 |
| Algeria | Middle East | 2400000 | 32900000 | 75012000000 |
| Andorra | Europe | 468 | 64000 | |
| ... | ||||