mysql实现多个字段重复内容的查询
表结构如下
time sip dip port
2012-04-20 14:50:41 192.168.12.117 192.168.1.100 1173
2012-04-20 14:50:41 192.168.12.117 192.168.1.100 1173
2012-04-20 14:50:41 188.222.61.224 192.168.120.189 23690
2012-04-20 14:50:41 192.168.16.1 192.168.12.117 0
2012-04-20 14:50:41 139.86.96.146 192.168.120.189 23690
2012-04-20 14:50:41 192.168.12.117 192.168.1.100 1173
想要将sip、dip、port三项都相同的按 重复的次数从高到底排序 输出top20
结果应该是这样
2012-04-20 14:50:41 192.168.12.117 192.168.1.100 1173 3次
2012-04-20 14:50:41 188.222.61.224 192.168.120.189 23690 2次
2012-04-20 14:50:41 192.168.16.1 192.168.12.117 0 1次
如何用mysql实现,请大牛指点下?
------解决方案--------------------
create table syn_count as select srcip,dstip,dstport,count(*) from syn
group by srcip,dstip,dstport