Sql COUNT() Function
COUNT() Function:- The COUNT() function returns the number of rows that matches specified criteria.



- SQL COUNT(column_name) Syntax :-
The COUNT(column_name) function returns the number of values of the specified column.
SELECT COUNT(column_name)
FROM table_name;
- SQL COUNT(*) Syntax:- This function returns the number of records in a table.
SELECT COUNT(*)
FROM table_name;
- SQL COUNT(DISTINCT column_name) Syntax:- This function returns the number of distinct values of the specified column.
SELECT COUNT(DISTINCT column_name)
FROM table_name ;
EXAMPLE:-
Consider the following CUSTOMERS table:-
- SQL COUNT(column_name) Example :-
SELECT COUNT(CustomerID) As ID
FROM CUSTOMERS ;
OUTPUT:-
SQL COUNT(*) Example :-
SELECT COUNT(*) AS total
FROM CUSTOMERS
WHERE salary < 15000 ;
OUTPUT:-
Comments
Post a Comment