A dashboard displays “120 customers,” but nobody can explain whether that means 120 records, 120 populated customer references, or 120 different customer identifiers.
All three can be legitimate measurements. They are not interchangeable, and Oracle’s COUNT expressions distinguish them directly.
A reliable count begins with a business definition. The SQL should then implement that definition rather than becoming the definition by accident.
Know what each expression measures
Oracle documents three relevant behaviors. COUNT(*) counts result rows, including duplicates. COUNT(expression) counts rows where that expression is not null. Adding DISTINCT counts distinct non-null expression values.
SELECT COUNT(*) AS row_count,
COUNT(customer_id) AS populated_ids,
COUNT(DISTINCT customer_id) AS distinct_ids
FROM customer_import;
These column names describe the measurements more accurately than labeling all three as customers.
Suppose an illustrative import contains five rows. Its customer identifiers are 10, 10, 20, null, and null. The expressions return five, three, and two respectively.
No result is inherently incorrect. Each answers a different question about the same data.
Use the differences to investigate quality
For an import review, comparing the counts can reveal where closer inspection is needed.
A gap between row count and populated identifiers indicates missing identifiers. A gap between populated identifiers and distinct identifiers shows repeated identifier values.
Those differences do not establish the cause. Repeated identifiers could represent duplicate records, legitimate multiple observations, or a misunderstood file structure.
Inspect sample records before applying a correction. Removing duplicates without understanding what one row represents can discard meaningful information.
The count is a diagnostic starting point, not a complete explanation of the dataset.
Match the metric to its intended audience
An operations team may need to know how many records arrived. A customer-success team may need the number of different customer accounts represented. A data-quality report may focus on missing references.
Give each metric its own label and definition. If a dashboard uses “active customers,” document the activity condition as well as the counting expression.
The reporting period matters too. A distinct count within one month cannot automatically be added to another month’s distinct count to obtain a distinct count across both months. The same identifier may appear in each period.
For example, two monthly lists containing the same customer do not represent two different customers when combined.
Test cases should expose ambiguity
Create a small dataset containing repeated identifiers, missing identifiers, and records outside the reporting condition. Write the expected results before executing the query.
Then check the complete query, including its joins and filters. The counting expression measures the rows supplied to it; an earlier step can change those rows.
Avoid switching to DISTINCT simply because a number looks too large. First establish whether repetition is expected and whether the query represents the correct business population.
Finally, retain the definition beside the report or in its documentation. A technically correct count can still mislead when a reader assumes it measures something else.
Good reporting makes both the number and its meaning visible.
Sources: Oracle: COUNT

