Hello developers, We found an assertion failure in SQLite version 3.37.0 2021-11-06 20:25:29 **with --enable-debug**. The test case is as follows: ``` CREATE TABLE t0(a); SELECT a FROM t0 LEFT JOIN (SELECT a AS b FROM t0) AS t1 WHERE (a,1)=(SELECT 2,2 UNION SELECT total(b),max(b) OVER(ORDER BY b) ORDER BY 2 DESC) AND b=4 ORDER BY b DESC; ``` which causes: > sqlite3.c: char sqlite3TableColumnAffinity(const Table *, int): Assertion `iCol\<pTab->nCol' failed. in line: > assert( iCol\<pTab->nCol ); Bisecting shows the issue may be related to [check-in 0d11d777c8](https://sqlite.org/src/info/0d11d777c8). **For other readers, please be assured that this is not a problem in release builds.** Hope the problem will be handled properly :)