## Summary
<!--Explain briefly what goes wrong and explain why you believe this is a bug and not the intended behavior of SQLite (if it is not a crash).-->**No review yet**

## Minimized query

```sql
PRAGMA case_sensitive_like = YES;
PRAGMA user_version;
PRAGMA wal_checkpoint('NOOP');
.timer 192319231923
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(w INT, x INT);
INSERT INTO t1(w,x) VALUES(1,10),(2,20),(3,30), (2,21),(3,31), (3,32);
CREATE INDEX t1wx ON t1(w,x);

DROP TABLE IF EXISTS t2;
CREATE TABLE t2(w INT, y VARCHAR(8));
INSERT INTO t2(w,y) VALUES(1,'one'),(2,'two'),(3,'three'),(4,'four');
CREATE INDEX t2wy ON t2(w,y);

SELECT cnt, xyz, (SELECT y FROM t2 WHERE w=cnt), '|' FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2) ORDER BY cnt, xyz;
SELECT cnt, xyz, lower((SELECT y FROM t2 WHERE w=cnt)), '|' FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2) ORDER BY cnt, xyz;
SELECT cnt, xyz, CASE WHEN (SELECT y FROM t2 WHERE w=cnt)=='two' THEN 'aaa' ELSE 'bbb' END, '|' FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2) ORDER BY +cnt;

WITH cte AS (SELECT * FROM t2 WHERE w IN (SELECT w FROM t2 LIMIT 5)) SELECT * FROM cte;
REINDEX;
```

## Actual output

```sql
0
0|-1|-1
Run Time: real 0.000 user 0.000019 sys 0.000000
Run Time: real 0.000 user 0.000121 sys 0.000000
Run Time: real 0.000 user 0.000030 sys 0.000000
Run Time: real 0.000 user 0.000084 sys 0.000000
Run Time: real 0.000 user 0.000005 sys 0.000000
Run Time: real 0.000 user 0.000053 sys 0.000000
Run Time: real 0.000 user 0.000016 sys 0.000000
Run Time: real 0.000 user 0.000052 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000 user 0.000089 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000 user 0.000055 sys 0.000000
1|1|bbb||
2|2|aaa||
3|3|bbb||
Run Time: real 0.000 user 0.000052 sys 0.000000
1|one
2|two
3|three
4|four
Run Time: real 0.000 user 0.000097 sys 0.000000
Run Time: real 0.001 user 0.000047 sys 0.000000
```

## Expectation

```sql
0
0|-1|-1
Run Time: real 0.000005 user 0.000015 sys 0.000000
Run Time: real 0.000066 user 0.000066 sys 0.000000
Run Time: real 0.000023 user 0.000024 sys 0.000000
Run Time: real 0.000051 user 0.000052 sys 0.000000
Run Time: real 0.000003 user 0.000003 sys 0.000000
Run Time: real 0.000030 user 0.000031 sys 0.000000
Run Time: real 0.000010 user 0.000011 sys 0.000000
Run Time: real 0.000030 user 0.000030 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000068 user 0.000068 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000036 user 0.000036 sys 0.000000
1|1|bbb||
2|2|aaa||
3|3|bbb||
Run Time: real 0.000031 user 0.000032 sys 0.000000
1|one
2|two
3|three
4|four
Run Time: real 0.000084 user 0.000084 sys 0.000000
Run Time: real 0.000016 user 0.000016 sys 0.000000
```

## Flag

```

```

