SQLite Forum

Using coalesce in where clause
Login
You can use coalesce anywhere, including the where clause, yes.

So there's something going on. First question is to ask when you say you have many rows with var = 7, are you sure that those are the number 7, or could they be the single character text string of '7'?

For the ON clause, if you're just looking to make it so nulls on either side match each other, you can use IS. That way if they're both null it'll still return true.
...
on a.col1 IS b.col1
...