--如果info是ntext,你下面这句根本就执行不了
select distinct info,name,Dt from Table1 where name<>'' and info <>''
order by Dt

解决方案 »

  1.   

    因為隻有info 字段有重復的記錄,而你的語句是針對三個字段的,所以查不出
      

  2.   

    查重復的記錄:select a,b,c 
    from table
    group by a,b,c
    having count(*)>1
      

  3.   

    是因为时间的问题,用 convert(varchar(10),DT,120)
      

  4.   

    --大家有没有看清楚,楼主的info字段是ntext--而ntext根本就不支持distinct--先不管楼主的语句是否能达到效果,至少语句要能执行啊--测试
    create table Table1(name char(10),info ntext,Dt datetime)
    go--查询方式1(楼主自己的)
    select distinct info,name,Dt from Table1 where name<>'' and info <>''
    order by Dt
    go--查询方式人(progress99(如履薄冰)的)
    select name,info,dt
    from table1
    group by name,info,dt
    having count(*)>1
    go--删除测试环境
    drop table Table1/*--测试结果
    服务器: 消息 8163,级别 16,状态 3,行 3
    不能以 DISTINCT 方式选择 text、ntext 或 image 数据类型。
    服务器: 消息 306,级别 16,状态 2,行 3
    不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。
    --*/
      

  5.   

    没错,text,ntext,image这些字段也不可能作group地
      

  6.   

    已经将ntext改成char型了,请指教
      

  7.   

    select info,name,Dt=max(dt) 
    from Table1 
    where name<>'' and info <>''
    group by Dt
      

  8.   

    你所谓的重复是指什么?  info相同就算重复,还是 info+name相同就算重复
      

  9.   

    我的info字段有重复记录的,按你写的还是有重复记录
      

  10.   

    --写错了,改:select info,name=max(name),Dt=max(dt) 
    from Table1 
    where name<>'' and info <>''
    group by info
    order by dt