Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
Javatpoint Logo
Javatpoint Logo

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:

MariaDB Count function 1

Count "student_id" from "Students" table:

Output:

MariaDB Count function 2

It shows 8 rows of student_id is available in "Students" table.

Now count "admission_date" from "Students" table:

Output:

MariaDB Count function 3

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:

MariaDB Count function 4

COUNT () Function with Distinct Clause

DISTINCT Clause is used with COUNT () function to prevent duplicate counting. It consists of only original records.

Output:

MariaDB Count function 5

It shows only 2 counts because "student_name" Ajeet has duplicate entries in the table.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA