GEOG 868
Spatial Database Management

Lesson 3 Practice Exercise Solutions

PrintPrint
  1. SELECT * FROM states WHERE pop2008 > 10000000;
  2. SELECT * FROM cities WHERE capital = 1;
  3. SELECT * FROM states WHERE name LIKE 'New%';
  4. SELECT * FROM cities WHERE name LIKE '%z%';
  5. SELECT * FROM states ORDER BY pop2008 DESC;
  6. SELECT * FROM states ORDER BY sub_region, name;
  7. SELECT * FROM states WHERE pop2008 > 10000000 AND sub_region = 'Pop';
  8. SELECT * FROM cities WHERE stateabb IN ('US-NY','US-NJ','US-PA');
  9. SELECT state, (white::double precision/total) * 100 AS pctwhite FROM census2010;
  10. SELECT sub_region, Sum(pop2008) FROM states GROUP BY sub_region;
  11. SELECT states.name, census2010.total, states.geom
    
        FROM states INNER JOIN census2010
    
        ON states.name = census2010.state;
  12. SELECT states.sub_region, Avg(census2010.male)
    
        FROM states INNER JOIN census2010
    
        ON states.name = census2010.state
    
        GROUP BY states.sub_region;