我有一张表:
id ip count time city country
1 217.165.93.78 1 2013-08-05 02:24:10 DUBAI UNITED ARAB EMIRATES
2 122.178.229.243 1 2013-08-06 02:25:37 BANGALORE INDIA
3 27.97.27.185 1 2013-08-06 02:26:48 PUNE INDIA
4 217.165.93.78 1 2013-08-06 02:39:12 DUBAI UNITED ARAB EMIRATES
我需要根据日期对ip进行分组。
答案 0 :(得分:0)
我不确定我的问题是否正确,但
怎么样?select DATE_FORMAT(time, '%d-%m-%Y'), ip
from testtable
group by DATE(time), ip;
但请提供预期的结果示例
答案 1 :(得分:0)
select `id`, `ip`, count(*) count , `time`, `city`, `country` from table1
group by ip
如果您想按日期查看
select `id`, `ip`, count(*) count , `time`, `city`, `country` from table1
where DATE_FORMAT(time, '%Y-%m-%d') = '2013-08-05'
group by ip
答案 2 :(得分:-2)
尝试使用:group by Convert(varchar(10),time,103)