Loading...
Select Version
Function group: aggregate function
COUNT(*) counts the rows in a table. Rows containing NULL values are included in the count.
COUNT (*)
Result
Without GROUP BY clause:
Returns the number of rows in the derived table of the corresponding SELECT expression (or corresponding SELECT statement). Duplicate rows and rows containing only NULL values are included.
With GROUP BY clause:
Returns the number of rows per group for each group in the derived table.
Data type: DECIMAL(31,0)
Examples
SELECT without GROUP BY:
Query the number of customers living in Munich in the CUSTOMERS table (result: 3):
SELECT COUNT(*) FROM customers WHERE city='Munich'
SELECT with GROUP BY:
Count the customers for each city:
SELECT city, COUNT(*) FROM customers GROUP BY city city Berlin 1 Bern 33 1 Hanover 1 Moenchengladbach 1 Munich 3 New York, NY 1