要取出所有mphone的sendtime的最新数据.怎么取??

解决方案 »

  1.   

    select mphone,max(sendtime) from TB group by mphone
      

  2.   


    select mphone,sendtime from tb order by ID desc
      

  3.   

    select * from tb aa where SendTime=(select SendTime=Max(SendTime) from tb a where a.MPhone=aa.MPhone)
      

  4.   

    select * from tb a where not exists(select 1 from tb b where a.mphone = b.mphone and a.sendtime < b.sendtime)
      

  5.   

    select * form TB A where not exists(select 1 from TB where a.mphone=mphone And a.sendtime<sendtime)
      

  6.   

    select * FROM  TB t where sendtime=(select max(sendtime)  from tb where mphone=t.mphone)
      

  7.   

    select top 1 *,from TB ore by  id desc
      

  8.   

    SELECT mphone,sendtime from 
    (
      select 
      mphone
      ,sendtime 
      ,RANK() OVER (Patition by mphone, Order by sendtime DESC) AS rank
      from TB 
    ) as a
    Where rank =1
      

  9.   

    对字段sendtime建立非聚集索引,再利用SQL查询语句,其速度很快