Examples of the count query in sql

count query in sql : The “COUNT” function in SQL is used to count the number of rows in a table or the number of rows that meet a specific condition.

The basic syntax of the “COUNT” function is as follows:

SELECT COUNT(*) FROM [table name];

Here, COUNT(*) counts the total number of rows in the specified table.

If you want to count the number of rows based on a specific condition, you can use the “WHERE” clause in the query, like this:

SELECT COUNT(*) FROM [table name] WHERE [condition];

For example, to count the number of employees with a salary greater than $50,000 in the “employees” table, you can use the following query:

SELECT COUNT(*) FROM employees WHERE salary > 50000;

Leave a Comment