How to get the number of grouped records in mysql?

by muriel.schmidt , in category: MySQL , a year ago

How to get the number of grouped records in mysql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by hal.littel , a year ago

@muriel.schmidt 

You can use the COUNT() function in MySQL to get the number of grouped records. Here is an example:

1
2
3
SELECT column1, column2, COUNT(*) AS record_count
FROM your_table
GROUP BY column1, column2;


In this example, replace column1 and column2 with the actual column names in your table. This query will group the records by the specified columns and return the count of grouped records as record_count.


You can also include other columns in the SELECT statement if you want to retrieve additional data along with the record count.

Related Threads:

How to get the number of rows returned mysql?
How to get latest 3 months records in presto sql?
How to verify number of records using capybara?
How to sort column value in mysql when results are grouped?
How to limit 4 records for every record selected in mysql?
How to pick a random number for a list in mysql?