sqlite> SELECT * FROM t GROUP BY b; 2|5 4|6 (for each b: one (unpredictable) value of a) sqlite> SELECT * FROM (SELECT * FROM t ORDER BY a DESC) GROUP BY b; 1|5 3|6 (for each b: the row with min a) sqlite> SELECT * FROM (SELECT * FROM t ORDER BY a ASC) GROUP BY b; 2|5 4|6 (for each b: the row with max a)
使用:
SELECT MIN(t.a) AS A, t.b FROM TABLE t GROUP BY t.b