为什么要建视图?select count(1)
from 表
group by id

解决方案 »

  1.   

    --参考
    select * from tbl where id in (
      select id from tbl group by id 
       having count(1)>1 )
      

  2.   

    select id,count=count(1)
    from 表
    group by id
      

  3.   

    --如果显示有相同记录的记录数select id,count(1) as 记录数
    from tbl  
    group by id
    having count(1)>1
      

  4.   

    现在要查找一组设备列表,按照设备的使用频率来排序,使用频率在历史记录中通过一段时间相同id的历史记录的条数来判断(用一次就增加一条包括时间信息的记录),现有设备表(equId,.....) 历史记录表(equId,time,......),怎样来对设备列表排序,效率最好
      

  5.   

    select count(1), from table group by id having count(*)>1