Fix a query that doesn't work in the newer version of sqlite