Tech Junkie Blog - Real World Tutorials, Happy Coding!: SQL: COUNT() Aggregate Function

Thursday, August 12, 2021

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

Search This Blog