WHERE Priority

Rookie question... But without brackets the below is confusing me.

WHERE DisDate >= xxxxxxxx
OR EndDate >= xxxxxxxx
AND DisDate IS NULL

Should this perform like A or B?

A:
    WHERE (DisDate >= xxxxxxxx
    OR EndDate >= xxxxxxxx)
    AND DisDate IS NULL


B:
    WHERE DisDate >= xxxxxxxx
    OR (EndDate >= xxxxxxxx
    AND DisDate IS NULL)

There are RULES given by SQL . ...

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/operator-precedence-transact-sql?view=sql-server-2017

I think first AND then OR

B. The AND is done first. Quick proof:

SELECT 1
WHERE 1 = 1 OR 1 = 1 AND 1 = 2

SELECT 1
WHERE (1 = 1 OR 1 = 1) AND 1 = 2
1 Like