日期:2014-05-17  浏览次数:20501 次

求一个SQL语句, 关于成组出现最多的~~
我的订单明细表:
BillID(订单编号)   code(商品编号)  qty(数量)
1                        a                       1
1                        b                       2           
1                        c                       1
2                        a                       2
2                        d                       1
3                        a                       2
3                        b                       1
3                        d                       2
4                        d                       1
5                        a                        2
5                        d                        1  
求一个SQL语句,  统计出所有订单明细表里搭配销售出现最多的商品并排序(订单明细里的商品必须有2个), 

结果表:
code1(商品编号)  code2(商品编号)   cnt(搭配次数)   qty(总销售数量)
a                         d                          2               &n