SQL Interview: 81 COUNT(*) and COUNT(Column)
This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.
Section: Development Level: Medium
Question:
You execute the following code:
DROP TABLE IF EXISTS dbo.Table1;
GO
CREATE TABLE dbo.Table1
(
Column1 int NULL
);
GO
INSERT dbo.Table1 (Column1)
VALUES (1), (NULL), (NULL), (2);
GO
-- Query 1
SELECT COUNT(*), COUNT(Column1)
FROM dbo.Table1;
-- Query 2
SELECT COUNT(*), COUNT(Column1)
FROM dbo.Table1
WHERE Column1 = NULL;
What values will be returned for each query?
2025-09-25