也就是说,找不同cocode值的唯一的第一条记录

解决方案 »

  1.   

    SELECT TOP 1 * FROM TABLE GROUP BY COCODE ORDER TIME DESC
      

  2.   

    gaojie666(高洁) 这样子是不行的 group by 要不select 的是聚合函数,要不select 的字段放到group by中。谢谢!再帮我试试
      

  3.   

    --方法1.
    select * from dictform a
    where not exists(
    select * from dictform where cocode=a.cocode and Uptime>a.Uptime)
      

  4.   

    --方法2.
    select a.* 
    from dictform a,(select cocode,Uptime=max(Uptime) from dictform group by cocode)b
    where a.cocode=b.cocode and a.Uptime=b.Uptime
      

  5.   

    select cocode,min(AboutReason)  as AboutReason ,min(Uptime) as Uptime
    from dictform 
    group by cocode
      

  6.   

    以下方法肯定可以實現樓主要求
    前提:select identity(int,1,1) as myid,* into #t from dictform1.select distinct cocode ,AboutReason, Uptime  from #t where myid=(select min(myid) group by  cocode)
    2.select * from dictform a
    where not exists(
    select * from dictform where cocode=a.cocode and myid>a.id)