'How to retrieve the duplicate or closet records in the SQL?

Trying to find the closest records based on the row values in the table.

id name num_1 place trn_num
101 Rock 123 UK 9988
1022 Rock_ 124 UK 9988
1213 ded 1233 Non UK 99881
1212 Deds 1233 Non UK 99881
1214 Feg 321 UK 8811
134 Rock 123 UK 9988

Based on the data, need to retrieve the closet matches like here id - 101, 1022, 134 are closet records and id 1213 and 1212 are closets.

Closet matches - Retrieve the closest records based on the row value match.

Which method should use in the SQL?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source