我有一张像这样的桌子:
| ID | value |
| 0 | 5 |
| 1 | 2 |
| 0 | 1 |
| 1 | 6 |
| 2 | 3 |
| 2 | 8 |
| 1 | 2 |
| 0 | 1 |
| 2 | 4 |
我试图在我的结果中只接受一行 id ,其中 value 是所有列的最小值,例如:
SELECT DISTINCT * FROM table WHERE MIN(table.value) = table.value
我该如何解决?谢谢!
编辑:
我想要的输出是:
| ID | value |
| 0 | 1 | -> is the min of all the rows with id = 0
| 1 | 2 |
| 2 | 3 |
编辑2:
就像是:
SELECT DISTINCT *
FROM tableName AS A
WHERE value = (SELECT MIN(value) From tableName AS B WHERE A.ID=B.ID)
但是tableName是(SELECT * FROM ...........)
..我该怎么做?