The COUNT() returns the number of column or rows that matches a specified criteria.
Syntax:-
The COUNT(column_name) returns the number of values of the specified column:-

SELECT COUNT(column_name) FROM table_name;

OR

SELECT COUNT(*) FROM table_name;

OR

SELECT COUNT(DISTINCT column_name) FROM table_name;
Example:-
The subsequent SQL counts the number of Visit from “VisitorID”=17 from the “Visitors” table:-

SELECT COUNT(VisitorID) AS VisitFromVisitorsID17 FROM Visitors WHERE VisitorID=7;

OR

SELECT COUNT(*) AS NumberOfVisits FROM Visitors;

Categories: SQL Function

0 thoughts on “SQL Count()”

Leave a Reply