In MySQL, the COUNT function is used to get the count of an expression.
SELECT COUNT (aggregate_expression) FROM table_name WHERE conditions;
Aggregate_expression: It is used to specify the column or expression to be utilised by the COUNT function.
ID NAME QUANTITY 1 Electronics 30 2 Sports 45 3 Fashion 50 4 Grocery 30 5 Toys 50
SELECT quantity, COUNT(*) AS “Number of Items” FROM items GROUP BY quantity;
QUANTITY Number of Items 30 2 45 1 50 2
The ‘items’ is an already existing table from which we are counting the number of Items of the same quantity value.