+-------------+------+
|Column Name |Type|+-------------+------+
| x | int || y | int |+-------------+------+
(x, y) is the primarykeycolumn (combination of columns withuniquevalues) for this table.
Eachrowof this table indicates the positionof a point on the X-Y plane.
The distance between two points p1(x1, y1) and p2(x2, y2) is sqrt((x2 -x1)2 + (y2 - y1)2).
Write a solution to report the shortest distance between any two points from the Point2D table. Round the distance to two decimal points.
Input:
Point2D table:+----+----+| x | y |+----+----+|-1|-1||0|0||-1|-2|+----+----+Output:
+----------+| shortest |+----------+|1.00|+----------+Explanation: The shortest distance is1.00 from point(-1,-1) to (-1,2).
To find the shortest distance between any two points, we need to compute the distance for every unique pair of points in the table. By joining the table with itself and excluding pairs where both points are the same, we can calculate all possible distances and select the minimum.