SQLite Forum

2 queries asking the same, give different answers
Login
> I tried your suggestion, but the query gives no result at all. I don't know what that can mean.

For your query [a], it means that the 2nd (EXCEPT ...) subquery returns the same set as, or a superset of, the 1st subquery.

[a. SELECT MAX("fld0"), fld0 FROM table EXCEPT SELECT MAX("fld0"), fld0 FROM table where ("fld1" = 'val1' or "fld1" = 'val2' or "fld1" = 'val3'); ]

Sometimes, a good way to debug a complex query is to break it down into its component subqueries, run those, and see what their individual result sets are.