Sunday, June 19, 2016

SQL: COUNT() Aggregate Function

The COUNT() function returns the number of rows in the specified table. There are two ways you can use COUNT(), which are the following:

  1. COUNT(*) count all the rows in the table including
  2. COUNT(column) return all the rows that contains value for the column, excluding the columns with null value

SELECT COUNT(*) AS NumberOfRows
FROM Customers







The query above returns the number of rows in the Customers table

SELECT COUNT(Region) AS NumberOfRows
FROM Customers

The query above counts the number of rows for the column "Region" that are not NULL



No comments:

Post a Comment