Recently i found that SQLite don\'t support DISTINCT ON()
clause that seems postgresql-specific. For exeample, if i have table t
with columns
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)
Use:
SELECT MIN(t.a) AS A,
t.b
FROM TABLE t
GROUP BY t.b