How to get highest count from list data in mysql?

Member

by larissa , in category: MySQL , a year ago

How to get highest count from list data in mysql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elisha_langworth , a year ago

@larissa 

To get the highest count from a list of data in MySQL, you can use the GROUP BY clause and the MAX() function.


Here's an example query to achieve this:


SELECT column_name, MAX(count_column) AS highest_count FROM table_name GROUP BY column_name;


Replace "column_name" with the name of the column you want to count and "count_column" with the column used to count the occurrences.


For example, if you have a table called "orders" with a column "product_name" and want to get the highest count of each product, you can use the following query:


SELECT product_name, MAX(count) AS highest_count FROM orders GROUP BY product_name;


This query will return the product name and the highest count for each product in the "orders" table.

Related Threads:

How to sort data from highest to lowest in chart.js?
How to get data from mysql on python flask?
How to get the last data of group by in mysql?
How to get stored data by delimiter ( ; ) in mysql?
How to count the number of data in laravel?
How to get data from two tables in mysql database using php?