How to count NULL values in SQL?

Anar Məmmədov
1 min readNov 27, 2022

--

as mentioned in the above title this also another tricky SQL query as well. We were talking about How to count unique value in any column in SQL in the previous article. We are going to talk about another topic is same like as previous article but a little bit different. So without further ado let’s get started.
Suppose we have a table EMPLOYEE as the following picture:

EMPLOYEE TABLE

So as we know when we counting record in SQL NULL values not counting, but sometimes we want to know that how many record keeping null values in any column in SQL aren’t we? So without any further ado let’s get started.

Write query like this and see the results like that:

SELECT COUNT(*)

FROM emp

WHERE mgr is null;

after that when query occur you are be able to see that result will be 1 because our MGR column only one record can contain null value.

--

--

Anar Məmmədov
Anar Məmmədov

Written by Anar Məmmədov

Java Backend Developer wondering RDBMS and processing of structure any technology that is related backend.

No responses yet