##### Welcome to Subscribe On Youtube

# Question

Formatted question description: https://leetcode.ca/all/612.html

Table: `Point2D`

+-------------+------+ | Column Name | Type | +-------------+------+ | x | int | | y | int | +-------------+------+ (x, y) is the primary key column for this table. Each row of this table indicates the position of a point on the X-Y plane.

The distance between two points `p`

and _{1}(x_{1}, y_{1})`p`

is _{2}(x_{2}, y_{2})`sqrt((x`

._{2} - x_{1})^{2} + (y_{2} - y_{1})^{2})

Write an SQL query to report the shortest distance between any two points from the `Point2D`

table. Round the distance to **two decimal points**.

The query result format is in the following example.

**Example 1:**

Input:Point2D table: +----+----+ | x | y | +----+----+ | -1 | -1 | | 0 | 0 | | -1 | -2 | +----+----+Output:+----------+ | shortest | +----------+ | 1.00 | +----------+Explanation:The shortest distance is 1.00 from point (-1, -1) to (-1, 2).

# Algorithm

- CROSS JOIN finds the distance between the current point and each point;
- Exclude self-connected records (distance is 0);
- Take min, take two decimal places

CROSS JOIN: https://stackoverflow.com/questions/17759687/cross-join-vs-inner-join-in-sql

# Code

SQL