select distinct(shop.shopid) as shopid,shop.logincount,shop.sortid,shop.img,shop.shopname,
shop.intro from cean_shop as shop inner join cean_shoptoBrand as brand  on shop.shopid=brand.shopid 
where shop.auditing='true'  order by shop.sortid desc,shop.logincount desc
提示
ntext 数据类型不能选为 DISTINCT,因为它不可比。
==============
因为通过联合查询,查出的shopid有重复的,想用distinct来去除,但查询的列中又要包含shop.img,shop.shopname。所以提示上面的错误。请教大家,应该要怎么解决呢。谢谢

解决方案 »

  1.   

    select distinct LTRIM(shop.shopid)  as shopid,shop.logincount,shop.sortid,shop.img,shop.shopname,
    shop.intro from cean_shop as shop inner join cean_shoptoBrand as brand  on shop.shopid=brand.shopid 
    where shop.auditing='true'  order by shop.sortid desc,shop.logincount desc
      

  2.   

    select distinct LTRIM(shop.shopid)  as shopid,shop.logincount,shop.sortid,shop.img,shop.shopname,
    shop.intro from cean_shop as shop inner join cean_shoptoBrand as brand  on LTRIM(shop.shopid)=brand.shopid 
    where shop.auditing='true'  order by shop.sortid desc,shop.logincount desc
      

  3.   

    用你的语句还是一样的错误提示
    如果我把,shop.img,shop.shopname,shop.intro去掉,就可以了。但我需要这三个字段的数据。
      

  4.   

    ntext 数据类型不能选为 DISTINCT,因为它不可比。
      

  5.   

    转成字符型吧CONVERT(VARCHAR(8000),你的字段)而且你DISTINCT 只能去除你列出的所有列中完全重复的
      

  6.   

    因为你其它的也是NTEXT或IMAGE类型是吧
      

  7.   


    select distinct LTRIM(shop.shopid)  as shopid,shop.logincount,shop.sortid,shop.img,shop.shopname,
    convert(varchar(50),shop.intro) from cean_shop as shop inner join cean_shoptoBrand as brand  on shop.shopid=brand.shopid 
    where shop.auditing='true'  order by shop.sortid desc,shop.logincount desc谢谢。。这样就可以了,我应该根据提示的错误进行查找原因
      

  8.   

    转换成varchar(8000)吧,varchar(max)
      

  9.   

    ntext 数据类型不能选为 DISTINCT,因为它不可比 
    尽量用varchar来代替
      

  10.   

    ntext 数据类型不能选为 DISTINCT,因为它不可比。