目标
我想做一个排名,我需要获得一列的 10 个第一。
问题
我的应用程序中有下表:
+------+---------+
| User | Product |
+------+---------+
| 1 | 1 |
+------+---------+
| 2 | 1 |
+------+---------+
| 3 | 1 |
+------+---------+
| 4 | 1 |
+------+---------+
| 5 | 2 |
+------+---------+
| 6 | 2 |
+------+---------+
| 7 | 2 |
+------+---------+
| 8 | 3 |
+------+---------+
| 9 | 3 |
+------+---------+
我想按照这种模式进行排名:
+---------+----------+
| Product | Quantity |
+---------+----------+
| 1 | 4 |
+---------+----------+
| 2 | 3 |
+---------+----------+
| 3 | 2 |
+---------+----------+
我怎样才能做到这一点?