NULL and COUNT(DISTINCT )

NULL is not determinate value and is not counted when the COUNT function is used with the DISTINCT keyword

For instance, if you SELECT DISTINCT MANAGER_ID from EMPLOYEES; you will get 19 rows with NULL among them.

 

 

However, if you do SELECT COUNT(DISTINCT MANAGER_ID) from EMPLOYEES; you will get just 18

 

It is a little tricky, so keep in mind. The guaranteed situation on the exam.

 

Leave a comment

Your email address will not be published. Required fields are marked *