Examples of the COUNT(*) Function

In the following example, the user wants to know the total number of rows in the orders table. So the user calls the COUNT(*) function in a SELECT statement without a WHERE clause:
SELECT COUNT(*) AS total_rows FROM orders;
The following table shows the result of this query.
total_rows
23
In the following example, the user wants to know how many rows in the orders table have a NULL value in the ship_instruct column. The user calls the COUNT(*) function in a SELECT statement with a WHERE clause, and specifies the IS NULL condition in the WHERE clause:
SELECT COUNT (*) AS no_ship_instruct FROM orders
   WHERE ship_instruct IS NULL;
The following table shows the result of this query.
no_ship_instruct
2
In the following example, the user wants to know how many rows in the orders table have the value express in the ship_instruct column. So the user calls the COUNT(*) function in the projection list and specifies the equals ( = ) relational operator in the WHERE clause.
SELECT COUNT (*) AS ship_express FROM ORDERS
   WHERE ship_instruct = 'express';
The following table shows the result of this query.
ship_express
6