Prev Next
SQL COUNT() function returns/counts the number of rows in a query. But, it will not count any null values/column in a table. Syntax for SQL COUNT() function is given below.
SQL Syntax for COUNT() function:
| Syntax for COUNT() function in SQL | SELECT COUNT(column_name) FROM table_name; |
| Syntax for COUNT(DISTINCT) function in SQL | SELECT COUNT(DISTINCT column_name) FROM table_name; |
| Syntax for COUNT(*) function in SQL | SELECT COUNT(*) FROM table_name; |
Please consider the following table with few records as given below.
Table name (for example): student
Column names in this table: Student_ID, Student_name, City and Marks
Available records: 4 rows
