如何从表中获取重复值的最大计数的输出,该表包含与列对应的重复值,这样就有多个不同的不同值具有最大计数。
考虑 r 下表数据:
+---------+------------+-------------+--------------+
| 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 |
+---------+------------+-------------+--------------+
我们在这里看到和的最大值count(customer_id)
是相同的。我想同时获得这两个值。C001
C002
最终输出应如下所示:
customer_id | count(customer_id) //max value
----------------+-----------------------
C001 | 2
C002 | 2
----------------+-----------------------