Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
17. Question 3


Alright, moving on to the third question.


Remember when Mark checked all the capitals that are within 500 kilometers of the New York? Well, Mark wants to know for sure whether there is a capital that would be more suitable to start one of his greatest trips.

For each state, show its name, its capital and the number of other capitals that are within 500 kilometers of its capital. Sort the results in descending order by the number of capitals within 500 kilometers and then by state names in ascending order.

Do not show states whose capitals don't have any neighboring capitals within 500 kilometers.