612 Shortest Distance in a Plane

https://leetcode.com/articles/shortest-distance-in-a-plane/

Note: To put the MIN() inside of SQRT() will slightly improve the performance.

select round(sqrt(min(pow((p1.x-p2.x),2)+pow((p1.y-p2.y),2))),2)  shortest

from point_2d p1, point_2d p2

where p1.x <> p2.x and p1.y <> p2.y

posted @ 2018-10-23 10:33  ffeng0312  阅读(297)  评论(0)    收藏  举报