78
MariaDB COUNT() Function
In MariaDB database, COUNT function is used to return the count of an expression.
Syntax:
The COUNT () Function counts only NOTNULL values.
Example:
We have a table “Students”, having the following data:
Count “student_id” from “Students” table:
Output:
It shows 8 rows of student_id is available in “Students” table.
Now count “admission_date” from “Students” table:
Output:
It shows only 7 rows of “admission_date” column because 1 field is NULL.
COUNT () Function with Single Expression
Count the number of students where “student_name” is “Ajeet” or “Kanchan”.
Output:
COUNT () Function with Distinct Clause
DISTINCT Clause is used with COUNT () function to prevent duplicate counting. It consists of only original records.
Output:
It shows only 2 counts because “student_name” Ajeet has duplicate entries in the table.
Next TopicMariaDB Sum Function