我有一个包含信息的数据库:
----------------------------------------------
| HighValue | LowValue | CurrentValue | Code |
----------------------------------------------
| 20 | 6 | 19 | GHI |
| 10 | 2 | 3 | ABC |
| 8 | 8 | 8 | JKL |
| 15 | 8 | 9 | DEF |
----------------------------------------------
我想找出哪些代码的当前值最接近最低值: 可能按顺序排列,如下:
----------------------------------------------
| HighValue | LowValue | CurrentValue | Code |
----------------------------------------------
| 8 | 8 | 8 | JKL |
| 10 | 2 | 3 | ABC |
| 15 | 8 | 9 | DEF |
| 20 | 6 | 19 | GHI |
----------------------------------------------
如何将列与此列的其他列进行比较?
答案 0 :(得分:1)
Select *
FROM yourtable
ORDER BY ABS(CurrentValue-LowValue)