Sql Query To use a ' SELECT ' statement with COUNT() function


To retrieve a count of the record of a specific column from the existing created table. Then we can use a ' SELECT ' statement with COUNT() function.

In 1st Statement will retrieve the count of total no. of record from the employees' table.

In 2nd Statement will retrieve the count of the total no. of name from the employees' table, but it will not calculate the name having a null field.

In 3rd Statement will retrieve the count of total no. of record from the employees' table, where employee_id is greater than 150.

In 4th Statement will retrieve the count of the total no. of name from the employees' table, where employee_id is greater than 150. but it will not calculate the name having a null field.

Enter - Select * from table_name;
SQL Query
SELECT COUNT(*) FROM employees; SELECT COUNT(phone_number) FROM employees; SELECT COUNT(*) FROM employees WHERE employee_id>150; SELECT COUNT(phone_number) FROM employees WHERE employee_id>150;
Output