SQLite Forum

2 queries asking the same, give different answers
Login
Hello,

Can someone shed light on the problem below?

In c# I created a simple SQLite database with about 900.000 records in one table, each record having 19 fields.

In the table three groups of records can be distinguished based on three different values of one and the same field "fld1".

one group having a field "fld1" = 'val1'
second group having a field "fld1" = 'val2'
third group having a field "fld1" = 'val3'

In total these three groups make the above mentioned number of 900.00 records.

I use 3 queries:

Q1 = SELECT MAX("fld0") FROM table;
Q2 = SELECT MAX("fld0") FROM table where ("fld1" = 'val1' or "fld1" = 'val2' or "fld1" = 'val3');
Q3 = SELECT MAX("fld0") FROM table where (                   "fld1" = 'val2'                   );

Query Q1 queries the same 900.00 records as query Q2 and there outputs are identical.

What can be the reason, that Q3 gives an higher outcome than Q2?
Even worse: the higher outcome of Q3 can not be found in the table.

It's all done on a windows 10 64 bit I7 laptop.

Any suggestion will be highly appriciated.

Kind regards,
jeroen van Dael