如图所示——
  首先怎么根据Moblie字段值出现的最后一次记录次数 来修改MoblieCount的值? 此表可看出也就是 id 65 的Mobile字段最后一个是152.       第二个 怎么将Mobile 字段出现的过的 152 的MoblieCount 进行 求和。  比如 这里其实就  152的总分为 50分。最后 拜谢 大家!

解决方案 »

  1.   

    update tb set...
    where id =(select top 1 id from tb order by MoblieTime desc)selecr sum(MoblieCount) from tb
     where Moblie=(select top 1 Moblie from tb order by MoblieTime desc)
      

  2.   


    1、
    update 你的表名 set MoblieCount=88 where id = (select top 1 id from 你的表名 order by MobileTime desc);2、按照Mobile分组统计,然后根据Mobile的条件进行过滤
    select sum(MoblieCount ) as 次数 from 你的表名 where Mobile =152 group by Mobile; 
      

  3.   

    首先第一问。
    你要把 select 出来的结果排序,比如ID列是自增的,那就用ID列倒序取第一个。
    然后就自己爱怎么修改了。比如:update 表名 set MoblieCount=xxx where Moblie=(select top 1 Moblie from 表名 order by id desc)如果要使 MoblieCount=Moblie 的话:update 表名 set MoblieCount=Moblie where Moblie=(select top 1 Moblie from 表名 order by id desc)MoblieCount 求和也一样:
    select sum(MoblieCount) from 表名 group by Moblie where Moblie=(select top 1 Moblie from 表名 order by id desc)