Counting Rows in a Table

You can count rows in a table to determine:

When you count values in a column, nulls are not included in the count. For example, you might count the number of books in a titles table that have values in the advance column. By default, the count includes all values, not just unique values.

The procedures for all three types of counts are similar.

To count all the rows in a table

  1. Start the query by adding the table you want to summarize to the Diagram pane.

  2. From the Query menu, choose Group By. The Query Designer adds a Group By column to the grid in the Grid pane.

    Check * (All Columns) in the input source window for the table.

    The Query Designer automatically fills the term Count into the Group By column in the Grid pane and assigns a column alias to the column you are summarizing to create a useful column heading in query output. For more details, see Creating Column Aliases.

To count all the rows that meet a condition

  1. Start the query by adding the table you want to summarize to the Diagram pane.

  2. From the Query menu, choose Group By. The Query Designer adds a Group By column to the grid in the Grid pane.

  3. Check * (All Columns) in the input source window for the table.

    The Query Designer automatically fills the term Count into the Group By column in the Grid pane and assigns a column alias to the column you are summarizing to create a useful column heading in query output. For more details, see Creating Column Aliases.

  4. Add the data column that you want to search, and then clear the check box in the Output column.

    The Query Designer automatically fills the term Group By into the Group By column of the grid.

  5. Change Group By in the Group By column to Where.

  6. In the Criteria column for the data column to search, enter the search condition.

To count the values in a column

  1. Start the query by adding the table you want to summarize to the Diagram pane.

  2. From the Query menu, choose Group By. The Query Designer adds a Group By column to the grid in the Grid pane.

  3. Add the column that you want to count to the Grid pane.

    The Query Designer automatically fills the term Group By into the Group By column of the grid.

  4. Change Group By in the Group By column to Count.

To count only unique values, choose Count Distinct.