To find the number of null values in the manager_id column (in the l_employee ta
ID: 3778871 • Letter: T
Question
To find the number of null values in the manager_id column (in the l_employee table), Jon wrote the following two SQL statements and claims that the two statements are equivalent. Do you agree with Jon? Briefly explain your answer.
Statement 1:
SELECT count(*)
FROM l_employees
WHERE manager_id is null;
Statement 2:
SELECT (count (*)) - (count (manager_id)) as null_values
from l_employees;
Query1 L EMPLOYEES EMPLOYEE ID FIRST NAME LAST NAME DEPT CODE HIRE DATE CREDIT LIMIT PHONE NUMBER MANAGER Click to Add 6/1/1998 $30.00 3484 01 Susan Brown Exe Kern Sal 8/16/1999 $25.00 8722 202 Jim 201 shp $25.00 7591 2/2/2009 203 Martha Woods 201 7/1/2008 $15.00 6830 204 Ellen Owens Sa 202 sal 205 Henry 3/1/2006 $25.00 5286 Perkins 202 206 Carol Rose Act Smith shp 12/1/2008 $25.00 2259 203 207 Dan Campbell shp 4/1/2008 $25.00 1752 208 Fred 203 Mkt $15.00 3357 3/17/1999 209 Paula Jacobs 201 Sal Hoffman $25.00 2974 2/16/2007 210 Nancy 203Explanation / Answer
SELECT count(*)
FROM l_employees
WHERE manager_id is null;
---------------------------------------------------------------------
SELECT (count (*)) - (count (manager_id)) as null_values from l_employees;
----------------------------------------------------------------------
yes both the statements are correct in the
=>first statement we put count on the table and getting only the null colomn so we will get number of null column count
=>and coming to the second statement we are taking the entire count of column both the null and not null
values and substracting the count of notNULL values to give null values count
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.