Difference between revisions of "Get the 11th to the 20th rows of the cia table - by population."

From SQLZOO
Jump to: navigation, search
Line 1: Line 1:
 
Get the 11th to the 20th rows of the bbc table - by population.
 
Get the 11th to the 20th rows of the bbc table - by population.
 
<div class='ht'>
 
<div class='ht'>
</source>
 
 
<source lang='sql' class='def e-sqlite'>SELECT name, population FROM bbc
 
<source lang='sql' class='def e-sqlite'>SELECT name, population FROM bbc
 
  ORDER BY population DESC LIMIT 10 OFFSET 10
 
  ORDER BY population DESC LIMIT 10 OFFSET 10

Revision as of 09:55, 18 July 2012

Get the 11th to the 20th rows of the bbc table - by population.

SELECT name, population FROM bbc
 ORDER BY population DESC LIMIT 10 OFFSET 10
SELECT TOP 10 x.name, x.population FROM (
 SELECT TOP 20 name, population FROM bbc
  ORDER BY population DESC) x
 ORDER BY x.population ASC
SELECT name, population FROM bbc
 ORDER BY population DESC LIMIT 10 OFFSET 10
SELECT name, population FROM (
 SELECT name, population, rownum n FROM (
   SELECT name,population FROM bbc
                        ORDER BY population DESC)
 )
WHERE n BETWEEN 11 AND 20
SELECT TOP 10 x.name, x.population FROM (
 SELECT TOP 20 name, population FROM bbc
  ORDER BY population DESC) x
 ORDER BY x.population ASC
SELECT * FROM bbc
 ORDER BY population DESC
 LIMIT 11, 10
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense