File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -371,3 +371,31 @@ ORDER BY
371
371
| 9 | 2513 | 3350 | 0.0000 |
372
372
| 10 | 2664 | 3304 | 0.0000 |
373
373
| 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 |
You can’t perform that action at this time.
0 commit comments