数据格式是这样的,两个字段,一个是id,一个是time,写个sql列出今天所有出现过3次以上的id,id不是索引。

解决方案 »

  1.   

    差不多如此
    select id,date(time),count(*)
    from tablename
    where time>=current_date()
    group by id,date(time)
    having count(*)>=3
      

  2.   

    select id from
    (select id,sum(id) as total from
    table
    where time=curdate()
    group by id)
    where total>3;
      

  3.   

    嗯,受楼上启发,简化一下select id 
    from tablename 
    where time>=current_date() 
    group by id
    having count(*)>=3 
    ;where那边用>=, 因为我假定你的time是datetime/timestamp类型
      

  4.   

    楼主没说是什么数据库啊,写一个sqlserver的select id
    from tb
    where datediff(dd,[time],getdate())=0
    group by id
    having count(1)>=3
      

  5.   

    select id 
    from table
    where time like curdate() 
    group by id
    having count(*)>=3;三楼的代码用模糊查询更准确点吧!
      

  6.   

    用db-getone,还是db-query或是其他
      

  7.   

    用db-getone,还是db-query或是其他
      

  8.   


    SELECT `id` FROM table WHERE FROM_UNIXTIME(`time`)=CURDATE() GROUP BY `id` HAVING COUNT(1) > 3