This aggregate function returns the number of duplicate rows in a dataset. Excluding the column to which the count is being applied (the reference column), all rows are examined column-by-column in order to find duplicate rows. Those rows that contain duplicate data are collapsed into a single unique row. The reference column receives a name change to become “Count of <column name>” and the number that appears in the column indicates the number of duplicate rows that have been collapsed.
Examples
The small dataset below will be used to show how count operates.
Column A | Column B | Column C |
---|
one | two | 5 |
one | two | 6 |
two | two | 7 |
one | two | 4 |
Example 1
Applying the count function to Column C reduces the row count from four to two. The value in the column Count of Column C shows the count of (number of times) duplicate rows that were collapsed during the operation.
Column A | Column B | Count of Column C |
---|
one | two | 3 |
two | two | 1 |
Example 2
Applying the count function to Column A results in no row count reduction since examination of Column B and Column C values in each row reveals that each is already unique. The value in the column Count of Column A therefore shows a value of 1 for each of the four rows.
Count of Column A | Column B | Column C |
---|
1 | two | 5 |
1 | two | 6 |
1 | two | 7 |
1 | two | 4 |