How can I get the output for maximum count of repeated values from a table, which contains the repeated values corresponding to a column such a way that there are multiple different distinct values having maximum-counts.
Consider r the table data below :
+---------+------------+-------------+--------------+
| Bill_No | Bill_Date | Customer_ID | Total_Amount |
+---------+------------+-------------+--------------+
| 101 | 2012-04-10 | C001 | 64 |
| 102 | 2012-04-10 | C002 | 8 |
| 103 | 2012-04-11 | C002 | 140 |
| 104 | 2012-04-13 | C001 | 29 |
| 105 | 2012-04-12 | C003 | 125 |
| 106 | 2012-04-16 | C004 | 258 |
+---------+------------+-------------+--------------+
We see here maximum count(customer_id)
is same for C001
and C002
. I want to get both values.
The final output should look like follows:
customer_id | count(customer_id) //max value
----------------+-----------------------
C001 | 2
C002 | 2
----------------+-----------------------