2

我有一张这样的桌子:

Date   | Expedition Name | Invoice
___________________________________________
4/6/12 | Starsindo       | X001908
4/6/12 | Starsindo       | X001900
4/6/12 | De Ros indah    | X002008
4/6/12 | De Ros indah    | X002108
4/6/12 | De Ros indah    | X002208
4/6/12 | Starsindo       | X002308
4/6/12 | Starsindo       | X002408
4/6/12 | Starsindo       | X002508 
4/6/12 | Japex           | X002608 

如何用mysql查询显示同一日期最常出现的三个远征队的名字?

我刚刚创建了这个查询,但仍然感到困惑:

Select  * From tb_exp_expor  Order By nama_exp_expor DESC
4

2 回答 2

7
 SELECT count(*) as counta,Expedition_name,Date 
    FROM tbl_exp_expor 
    group by Expedition_name,Date
    Order by counta DESC
    limit 3
于 2012-07-17T07:49:06.073 回答
0

我认为 StackOverflow 上的这个问题和答案(由danben 提供)可能会对您有所帮助:
mysql: Using LIMIT within GROUP BY to get N results per group?

它包含本文的链接:
How to select the first/least/max row per group in SQL

于 2012-07-17T09:40:36.443 回答