*********SQL中如何查询次数出现最多值(就一列,分不多.有兴趣的帮我一下啊).****************
有表 visitorinfo
dottime
------------------------------------------------------
2007-05-18 13:30:24.670
2007-05-18 13:30:24.793
2007-05-18 13:30:45.827
2007-05-18 13:30:45.890
2007-05-18 13:30:59.560
2007-05-18 13:30:59.780
2007-05-18 16:22:55.187
2007-05-18 16:32:25.233
2007-05-21 11:02:13.170
我想得到结果 2007-05-18 就是点击最多的那一天咋个实现?
最好给点思路.不要只写代码.谢个啦
------解决方案--------------------select max([countvalue])
from
(select count([dottime]) as countvalue
from
visitorinfo
group by [dottime]) as mytable
子查询首先根据dottime分组计算每个dottime的个数,然后再查询出最大的一个
在SQL Server 2005下通过
------解决方案--------------------不是没法分组,关键是怎么把一天的分到一个组里去
------解决方案--------------------以时间分组 当然count都是1了
------解决方案--------------------select a.Tcount from
(
select count(to_char(dottime, 'yyyy-MM-dd ')) as Tcount
from yourtable
group by dottime
) a
order by desc