COUNT(*) counts selected rows. COUNT(Copies) counts selected rows whose Copies value is not NULL. On the six supplied rows below, the answers are 6 and 3. Neither count is the sum of the numbers in Copies.
This is a read-only prediction exercise. Start with the complete fictional relation, apply each WHERE filter, then count. The expected outputs are documentation-derived, not a transcript of a MySQL session.
Read all six supplied rows
The original practice relation is PracticeLoans. ItemID is a unique integer identifier. Shelf is non-NULL text containing the exact uppercase labels shown. Copies is a nullable integer. NULL is a missing-value marker, not a quoted text value.
PracticeLoans: complete supplied relation
ItemID
Shelf
Copies
201
A
0
202
A
NULL
203
A
2
204
A
2
205
B
NULL
206
B
NULL
Keep items 203 and 204 separate even though their Copies values match. The zero in 201 is known. Items 202, 205 and 206 have missing Copies values, but their rows still exist.
Filter first, then ask two different questions
List the ItemIDs that satisfy the WHERE condition. With no WHERE, keep all six.
For TotalRows, count every retained row once, including rows with NULL in Copies.
For KnownCopies, cross out only the retained NULL Copies values, then count the remaining values once per row.
Read the column aliases. TotalRows and KnownCopies label the two counts; they do not change the source data.
Each query below selects only aggregates and has no GROUP BY. It returns a single result row containing the two counts, including when the filter selects no input rows. Do not confuse zero matching input rows with zero aggregate output rows.
Predict and check the six count results
All supplied rows
SELECT COUNT(*) AS TotalRows,
COUNT(Copies) AS KnownCopies
FROM PracticeLoans;
Selected ItemIDs: 201, 202, 203, 204, 205, 206.
One result row: TotalRows = 6; KnownCopies = 3.
All six rows exist. Copies is present in 201, 203 and 204. The repeated value 2 counts twice; known zero counts once.
Shelf A
SELECT COUNT(*) AS TotalRows,
COUNT(Copies) AS KnownCopies
FROM PracticeLoans
WHERE Shelf = 'A';
Selected ItemIDs: 201, 202, 203, 204.
One result row: TotalRows = 4; KnownCopies = 3.
The filter leaves four rows. Only 202 has a missing Copies value. Do not deduplicate the two rows with Copies equal to 2.
Shelf B: rows exist, all Copies missing
SELECT COUNT(*) AS TotalRows,
COUNT(Copies) AS KnownCopies
FROM PracticeLoans
WHERE Shelf = 'B';
Selected ItemIDs: 205, 206.
One result row: TotalRows = 2; KnownCopies = 0.
Two rows survive the filter, so COUNT(*) is 2. Both Copies values are NULL, so COUNT(Copies) is 0.
Shelf C: no matching rows
SELECT COUNT(*) AS TotalRows,
COUNT(Copies) AS KnownCopies
FROM PracticeLoans
WHERE Shelf = 'C';
Selected ItemIDs: none.
One result row: TotalRows = 0; KnownCopies = 0.
No supplied row has Shelf C. Both counts are 0, but the aggregate query still returns one result row. This query has no GROUP BY.
Known zero only
SELECT COUNT(*) AS TotalRows,
COUNT(Copies) AS KnownCopies
FROM PracticeLoans
WHERE Copies = 0;
Selected ItemIDs: 201.
One result row: TotalRows = 1; KnownCopies = 1.
Item 201 has a known numeric zero. That row contributes one to each count. COUNT(Copies) does not ask whether Copies is positive.
Missing Copies only
SELECT COUNT(*) AS TotalRows,
COUNT(Copies) AS KnownCopies
FROM PracticeLoans
WHERE Copies IS NULL;
Selected ItemIDs: 202, 205, 206.
One result row: TotalRows = 3; KnownCopies = 0.
Three rows satisfy the missing-value test. They contribute three to COUNT(*) and none to COUNT(Copies).
Explain why two zeros can mean different things
Shelf B and Shelf C both give KnownCopies equal to 0. They do not describe the same input. Shelf B has two matching rows with missing Copies; Shelf C has no matching row. TotalRows separates them: 2 versus 0.
For these queries on the same filtered rows, TotalRows minus KnownCopies counts missing Copies values. Across all supplied rows that is 6 - 3 = 3. This does not mean those rows are empty or invalid. It says only that this one column is NULL there.
If the predicate itself is the confusing part, first use the separate IS NULL and IS NOT NULL supplied-table exercise. That guide selects individual rows; this one summarizes the selected rows.
School relevance and limits
The CBSE 2026-27 Informatics Practices 065 syllabus, Class XII Unit 2, lists aggregate functions including COUNT and explicitly using COUNT(*). This practice targets that distinction. It is original EZ Tuitions material, not an official CBSE question or a reproduced NCERT table.
MySQL 8.4 is the reference-documentation version, not a CBSE-mandated server version. This page does not cover installation, imports, data changes, joins, grouped results, HAVING or performance. Do not transfer its one-output-row rule to queries with GROUP BY. No native application, server execution or UI result was observed.
Frequently asked questions
Does COUNT(Copies) add the Copies numbers?
No. It counts non-NULL values in the selected rows. Here the present values are 0, 2 and 2, so COUNT(Copies) is 3. Adding those values would answer a different question.
Does zero count in COUNT(column)?
Yes. Zero is a non-NULL numeric value. Item 201 contributes one to COUNT(Copies). A count of known values is not a count of positive values.
Are repeated values counted once?
Not by ordinary COUNT(Copies). Items 203 and 204 are different rows and each has a non-NULL Copies value, so both contribute. COUNT(DISTINCT Copies) is a separate expression with a different purpose.
How do I distinguish all missing values from no matching rows?
Read both counts. Shelf B gives TotalRows 2 and KnownCopies 0. Shelf C gives 0 and 0. COUNT(Copies) alone is 0 in both cases and cannot make that distinction.
Were these results observed on a MySQL server?
No. These are expected results derived from MySQL 8.4 documentation for an invented table. No server session, database import or application UI was observed. The guide does not claim native execution.
Sources and limits
Primary sources checked 27 November 2026. The MySQL manual defines the counts and missing-value behavior; the curriculum establishes school relevance. All supplied rows, queries and explanations are original practice.