会员登录记录表hy
hy_time 是日期字段,类型为getdate()会员每登录一次便记录一次我现在要用gridview统计出每天会员登录次数,格式为:
日期    登录总次数
6月1日    30人次
6月2日    20人次
6月3日    33人次我是这样写的:SELECT distinct hy_time from hy
得到的结果依然有重复的日期。
不知如何写SQL语句?

解决方案 »

  1.   

    select 日期字段,count(*) from 表名 group by 日期
      

  2.   

    datetime包含有时分秒
    时间就不一致,当然会重复sql检索有一个日期格式函数,不记得了,然后可以用  select 函数(日期),count(*)
               from table
              group by 函数(日期)
      

  3.   

    加个条件就可以了select distinct hy_time from hy where=这里是条件
      

  4.   

    select 日期字段,count(*) from 表名 group by 日期
      

  5.   

    Select COUNT(*), 日期
    FROM Tb
    GROUP BY 日期
    select convert(datetime,convert(char(10),[date],120)) as [date],
           count(*) from T
    group by convert(datetime,convert(char(10),[date],120))
      

  6.   

    select cola,sum(*) from tablea group by cola;