Difference between revisions of "Nested SELECT Quiz"
From SQLZOO
| Line 82: | Line 82: | ||
- SELECT name, region FROM bbc x WHERE population < ALL (SELECT population/3 FROM bbc y WHERE y.name != x.name) | - SELECT name, region FROM bbc x WHERE population < ALL (SELECT population/3 FROM bbc y WHERE y.name != x.name) | ||
| − | {Select the result that would be obtained from the following code: SELECT name FROM bbc WHERE population (SELECT population FROM bbc WHERE name='United Kingdom') AND region IN (SELECT region FROM bbc WHERE | + | {Select the result that would be obtained from the following code: |
| + | <source lang=sql> | ||
| + | SELECT name FROM bbc | ||
| + | WHERE population > | ||
| + | (SELECT population | ||
| + | FROM bbc | ||
| + | WHERE name='United Kingdom') | ||
| + | AND region IN | ||
| + | (SELECT region | ||
| + | FROM bbc | ||
| + | WHERE name = 'United Kingdom') | ||
| + | </source> | ||
<table><caption>Table-A</caption><tr><td>Andorra</td></tr><tr><td>Albania</td></tr><tr><td>Austria</td></tr><tr><td>Bulgaria</td></tr></table> | <table><caption>Table-A</caption><tr><td>Andorra</td></tr><tr><td>Albania</td></tr><tr><td>Austria</td></tr><tr><td>Bulgaria</td></tr></table> | ||
<table><caption>Table-B</caption><tr><td>France</td><td>Europe</td></tr><tr><td>Germany</td><td>Europe</td></tr><tr><td>Russia</td><td>Europe</td></tr><tr><td>Turkey</td><td>Europe</td></tr></table> | <table><caption>Table-B</caption><tr><td>France</td><td>Europe</td></tr><tr><td>Germany</td><td>Europe</td></tr><tr><td>Russia</td><td>Europe</td></tr><tr><td>Turkey</td><td>Europe</td></tr></table> | ||
Latest revision as of 19:47, 11 August 2012
Nested SELECT 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 | |
| Bangladesh | South Asia | 143998 | 152600000 | 67144000000 |
| United Kingdom | Europe | 242514 | 59600000 | 2022824000000 |
| ... | ||||