题目来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/shortest-distance-in-a-plane
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
本人思路:
– 1、会计算点点之间的距离即可
– 2、筛选条间注意要去掉自己与自己求距离,也可以使用(p1.x,p1.y) != (p2.x,p2.y)
select min(round(sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2)),2))as shortest
from point_2d as p1 ,point_2d as p2
where concat(p1.x,p1.y) != concat(p2.x,p2.y)