Example Customer Table
The following data table is for example only. Let's use COUNT() function to get the total rows/records from a customer table. The column we going to use are the Name and Age columns.
ID | Name | Age |
1 | Thomas Anderson | 45 |
2 | Andrew Golden | 38 |
3 | Ken Tom | 30 |
4 | Andrew Golden | 36 |
5 | Timothy Kirk | 32 |
6 | Kelly Smith | NULL |
Example of Running SQL Query
SELECT COUNT(Name) AS Total FROM Customers
After running the above query, it will return the following result.
Total |
6 |
Another example
Let's do another count to a column that contains a NULL value.
SELECT COUNT(Age) AS Total FROM Customers
After running the above query, it will return the following result.
Total |
5 |