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

From SQLZOO
Revision as of 15:17, 11 July 2012 by Connor (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

</source>

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

Variants
Actions
Reference
Toolbox
Google AdSense