SQLite
View Ticket
Not logged in
Ticket UUID: 98825a79ce145686392d8074032ae54863aa21a3
Title: Incorrect result from a DISTINCT + GROUP BY + ORDER BY query
Status: Fixed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2014-04-03 16:57:11
Version Found In: 3.8.4.2
User Comments:
drh added on 2014-04-03 15:17:34:

The following query answers 'wrong' even though the correct answer is 'right':

CREATE TABLE t1(x);
INSERT INTO t1 VALUES('right'),('wrong');
SELECT DISTINCT x
 FROM (SELECT x FROM t1 GROUP BY x)
 WHERE x='right'
 ORDER BY x;

Bisecting shows that this problem was introduced by check-in 1e64dd782a126f48d78c4 on 2014-02-08 and first appeared in SQLite version 3.8.4.