Difference between revisions of "SUM and COUNT Quiz"
From SQLZOO
| Line 67: | Line 67: | ||
- AVG(), COUNT(), MAX(), MIN(), SUM() | - AVG(), COUNT(), MAX(), MIN(), SUM() | ||
- COUNT(), SUM() | - COUNT(), SUM() | ||
| + | |||
| + | {Select the result that would be obtained from the following code: | ||
| + | |type="()"} | ||
| + | - Table-A | ||
| + | - Table-B | ||
| + | + TAble-C | ||
| + | - Table-D | ||
| + | - Table-E | ||
{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' | ||
|type="()"} | |type="()"} | ||
| − | - | + | - SELECT AVG(population) FROM bbc WHERE name = ('Poland', 'Germany', 'Denmark') |
| − | + | + | + SELECT AVG(population) FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark') |
| − | - | + | - SELECT AVG(population) FROM bbc WHERE name LIKE ('Poland', 'Germany', 'Denmark') |
| − | - | + | - SELECT AVG(population) FROM bbc WHERE name LIKE (Poland, Germany, Denmark) |
| − | - | + | - SELECT population FROM bbc WHERE name IN ('Poland', 'Germany', 'Denmark') |
{Select the statement that shows the medium population density of each region | {Select the statement that shows the medium population density of each region | ||
|type="()"} | |type="()"} | ||
| − | - | + | - SELECT region, AVG(population/area) AS density FROM bbc |
| − | - | + | - SELECT region, COUNT(population)/COUNT(area) AS density FROM bbc GROUP BY region |
| − | - | + | - SELECT region, SUM(population)/COUNT(area) AS density FROM bbc GROUP BY region |
| − | - | + | - SELECT region, SUM(population)/SUM(area) AS density FROM bbc HAVING region |
| − | + | + | + SELECT region, SUM(population)/SUM(area) AS density FROM bbc GROUP BY region |
{Select the statement that shows the name and population density of the country with the largest population | {Select the statement that shows the name and population density of the country with the largest population | ||
|type="()"} | |type="()"} | ||
| − | - | + | - SELECT name, density AS population/area FROM bbc WHERE population = MAX(population) |
| − | - | + | - SELECT name, density AS population/area FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) |
| − | - | + | - SELECT name, MAX (population) FROM bbc WHERE population / (SELECT area FROM bbc) |
| − | + | + | + SELECT name, population/area AS density FROM bbc WHERE population = (SELECT MAX(population) FROM bbc) |
| − | - | + | - SELECT name, population/area AS density FROM bbc WHERE population > (SELECT MAX(population) FROM bbc) |
| + | |||
| + | {Select the result that would be obtained from the following code: | ||
| + | |type="()"} | ||
| + | - Table-A | ||
| + | - Table-B | ||
| + | + TAble-C | ||
| + | - Table-D | ||
| + | - Table-E | ||
</quiz> | </quiz> | ||
[[Category:Quizzes]] | [[Category:Quizzes]] | ||
Revision as of 10:11, 7 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 | |
| ... | ||||