SQL COUNT_BIG function

The SQL COUNT_BIG Function is useful to Count the number of items/rows selected by the SELECT Statement. It works the same as the Count function, but it returns the bigint. For this SQL Server COUNT_BIG function, We are going to use the below shown data.

Aggregate Function Source Table 1

SQL Server COUNT_BIG (*) Example

The COUNT_BIG (*) returns the total number of records from the MyEmployees table. Let us see one example for a better understanding.

SELECT COUNT_BIG(*) AS [Number of Employees]
FROM [MyEmployees]

Above Query will count the total records present in the MyEmployees table

SQL COUNT_BIG Function 2

COUNT_BIG (Column Name) Example

The COUNT_BIG Column Name returns the records whose values are NOT NULL (Ignores the NULL Records). Let us see one Aggregate Function example.

SELECT COUNT_BIG([EmployeeID]) AS [Number of Employees]
      ,COUNT_BIG([ManagerID]) AS [Number of Managers]	
FROM [MyEmployees]
COUNT_BIG Column Name 3

SQL Unique Count_BIG Example

The COUNT_BIG (DISTINCT Column Name) returns the Unique number of records present in the specified column whose values are NOT NULL. The DISTINCT Keyword is used to remove the Duplicates in SQL Server.

SELECT COUNT_BIG(DISTINCT [EmployeeID]) AS [Number of Unique Employees]
      ,COUNT_BIG(DISTINCT [ManagerID]) AS [Number of Unique Managers]	
FROM [MyEmployees]
Unique COUNT BIG Function 4


In general, we write a Select query to check for the number of products that belongs to a particular category or color, etc. In these situations, we use the GROUP BY clause to group the products by color or category. We then use the COUNT_BIG Function to Count the number of products present in that group. Let us see the Example.

SELECT COUNT_BIG( [EmployeeID]) AS [Number of Employees]
      ,SUM([YearlyIncome]) AS [Total Income]
      ,SUM([Sales]) AS [Total Sale]
 FROM [MyEmployees]
 GROUP BY [Education]
 ORDER BY [Total Income] DESC
SQL COUNT_BIG Function 5
Categories SQL