Finding Pairs of Rows with Values Within 10% of Each Other

Write a SQL query to find all pairs of rows in a table where the values in the two columns are within 10% of each other.

Problem

Given a table of data with two columns, write a SQL query to find all pairs of rows where the values in the two columns are within 10% of each other.
Example input:
| Column1 | Column2 |
|---------|---------|
|    100  |    110  |
|    200  |    210  |
|    300  |    330  |
|    400  |    380  |
Example output:
| Column1 | Column2 |
|---------|---------|
|    100  |    110  |
|    200  |    210  |

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT * FROM table
WHERE ABS(Column1 - Column2) / Column1 < 0.1

A.I. Evaluation of the Solution

This solution is correct and demonstrates a level of completeness. It solves the problem and uses the correct SQL syntax. The approach is straightforward and easy to understand.

Evaluated at: 2022-11-22 02:16:01