-3

Why does this query always return NULL?

SELECT (Supervisor IS NULL) = (Supervisor = NULL) FROM Salespeople 

is it because we specify the second half with equal to null ?

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786

1 Answers1

2

Supervisor IS NULL returns TRUE or FALSE.

Supervisor = NULL always returns NULL.

Thus, TRUE = NULL or FALSE = NULL will always return NULL.

That's why your query will return NULL rows whose count will be the total row-count of your table.

fiddle.

Yigitalp Ertem
  • 1,901
  • 24
  • 27