Database Reference
In-Depth Information
geography(e.the_geom), 200000)
WHERE c.pop_2000 > 1000000
GROUP BY c.name, e.magnitude
ORDER BY c.name, e.magnitude,
hq_count;
name | magnitude | hq_count
----------------+-----------+---------
Chicago | 2 | 1
Chicago | 3 | 1
Dalla | 2 | 12
...
San Diego | 4 | 20
San Diego | 5 | 2
(18 rows)
3. As a variant of the previous query, executing the following code gives you
a complete list of earthquakes, along with their distance from the city (in
meters):
postgis_cookbook=# SELECT c.name,
e.magnitude,ST_Distance(geography(c.the_geom),
geography(e.the_geom)) AS distance FROM
chp03.cities AS c
JOIN chp03.earthquakes AS e
ON ST_DWithin(geography(c.the_geom),
geography(e.the_geom), 200000)
WHERE c.pop_2000 > 1000000
ORDER BY distance;
name | magnitude |
distance
-----------------+-----------+------------------
Dallas | 2 |
10801.3253855616
Los Angeles | 3 |
13740.7943591606
...
San Diego | 2 |
199062.753724934
Search WWH ::




Custom Search