Skip to content

Commit b4d3d54

Browse files
committed
added a sample query to the docs
1 parent 8fc32d1 commit b4d3d54

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/sample_queries.md

+28
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,31 @@ ORDER BY
371371
| 9 | 2513 | 3350 | 0.0000 |
372372
| 10 | 2664 | 3304 | 0.0000 |
373373
| 11 | 3148 | 3448 | 0.0000 |
374+
375+
#### Find which subway stations have most crimes commited within the distance of 500 meters (slow to execute)
376+
377+
```sql
378+
SELECT
379+
CAST(SUB.ID AS int) AS StationId,
380+
SUB.Name AS SubName
381+
, Count(*) AS CrimeCount
382+
FROM
383+
homicides AS Crimes
384+
JOIN
385+
SUBWAY_STATIONS AS SUB
386+
ON
387+
ST_Distance(SUB.Shape, Crimes.Shape) < 500
388+
GROUP BY
389+
SUB.ID, SUB.Name
390+
ORDER BY
391+
CrimeCount DESC
392+
LIMIT 5
393+
```
394+
395+
| | StationId | SubName | CrimeCount |
396+
|----:|------------:|:--------------------------|-------------:|
397+
| 1 | 85 | Sutter Ave | 43 |
398+
| 2 | 229 | Rockaway Ave | 38 |
399+
| 3 | 211 | Tremont Ave | 37 |
400+
| 4 | 212 | 182nd St | 37 |
401+
| 5 | 209 | 170th St | 36 |

0 commit comments

Comments
 (0)