I have a table like this:
+-----+------------+-------+--------+
| ID | val1 | val2 | val3 |
+-----+------------+-------+--------+
| 100 | 110 | 25 | 530 |
| 101 | 56 | 75 | 591 |
| 102 | 65 | 93 | 827 |
| 103 | 75 | 70 | 805 |
+-----+------------+-------+--------+
I want to write a query in postgreSQL that whenever (val3-val1) is minimum, returns the ID for me.
You could use
order by: