Does precedence of logical operators matter in libreoffice calc?

Viewed 48

I have the following query in libreoffice calc:

Extract records where grade is 1 or 2 and salary >= 10000 and salary <=20000

I used standard filters in the sequence grade = 1 or grade=2 and sal >= 10000 and sal<=20000

Using the above sequence, I am not getting the correct result

However, if I use the sequence as sal >= 10000 and sal<=20000 and grade = 1 or grade=2, then I am getting the correct result.

Is this due to Order of precedence?

Why I am getting different results?

1 Answers

Yes, you are right, it has to do with order.

In the first case, Calc tries to take records that meet the condition

grade = 1 or (grade=2 and sal >= 10000 and sal<=20000)

(All records for grade = 1 and additionally records for grade = 2 with sal between 10000 and 20000)

And in the second case, this condition

sal >= 10000 and sal<=20000 and (grade = 1 or grade=2)

That is exactly what you wanted to get.

You can read more details, for example, in Wikipedia

Wiki_About_Order_of_operations

Related