Introduction
Geometry vs. Geography
Summary

Instruction

Nicely done! Let's do one more exercise of this kind.

Exercise

Mark is curious as to how many state capitals are within 500 kilometers of the capital of New York.

Stuck? Here's a hint!

Use the COUNT(*) function and join usa_states state1 with usa_states state2. In the ON clause, use ST_Dwithin. Note that by default, New York will also be joined with itself, so you will have to use state1.name equal to New York in the WHERE clause AND state2.name not equal to state1.name.

Console

Code editor

Result

TableConsole