Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. CREATE TABLE close200 AS SELECT
  2. nyc_subway_stations.name,
  3. count(DISTINCT nyc_streets.name) count200
  4. FROM nyc_subway_stations, nyc_streets
  5. WHERE ST_DWITHIN(nyc_subway_stations.geom, nyc_streets.geom, 200)
  6. GROUP BY nyc_subway_stations.name
  7. ORDER BY count200 DESC;
  8.  
  9. CREATE TABLE close100 AS SELECT
  10. nyc_subway_stations.name,
  11. count(DISTINCT nyc_streets.name) count100
  12. FROM nyc_subway_stations, nyc_streets
  13. WHERE ST_DWITHIN(nyc_subway_stations.geom, nyc_streets.geom, 100)
  14. GROUP BY nyc_subway_stations.name
  15. ORDER BY count100 DESC;
  16.  
  17. CREATE TABLE proxMetro AS SELECT
  18. close100.name, close100.count100, close200.count200
  19. FROM close100, close200
  20. WHERE close100.name = close200.name;
  21. DROP TABLE close100, close200;
  22. SELECT * FROM proxMetro;
  23.  
  24. SELECT
  25. nyc_subway_stations.name,
  26. (SELECT count(DISTINCT nyc_streets.name) count100
  27. FROM nyc_subway_stations, nyc_streets
  28. WHERE ST_DWITHIN(nyc_subway_stations.geom, nyc_streets.geom, 100)),
  29. (SELECT count(DISTINCT nyc_streets.name) count200
  30. FROM nyc_subway_stations, nyc_streets
  31. WHERE ST_DWITHIN(nyc_subway_stations.geom, nyc_streets.geom, 200))
  32. FROM nyc_subway_stations, nyc_streets
  33. GROUP BY nyc_subway_stations.name
  34. ORDER BY count100 DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement