SQLite Forum

Help please importing data
That will have a problem if the subselect returns NULL (as in there are none) because an error will be thrown (datatype mismatch).

Putting the subquery in a where clause will work except that it will always return a single row (1) even if there are no rows in the subquery.

So both halves of the recursive CTE need to be fixed in order to get nothing returned if there is nothing to return.

generate_series does this automatically because the result of the test is always false (value <= stop) because anything compared to null is null (false) so nothing is returned.