日期:2014-05-18  浏览次数:20463 次

[疑难杂证]求救
我原来的句子是这样的,可以运行.
select   ChannelID,ClassID,Title,count(*)   from   PE_Article
group   by   ChannelID,ClassID,Title
having   count(*)> =2   and   ChannelID= '1035 '
但我在里面加了字段Content.
select   Content,ChannelID,ClassID,Title,count(*)   from   PE_Article
group   by   Content,ChannelID,ClassID,Title
having   count(*)> =2   and   ChannelID= '1035 '
就发生错误了.我Content是ntext类型的.请问怎么修改才能正确的显示数据..


------解决方案--------------------
select substring(Content,1,4000),ChannelID,ClassID,Title,count(*) from PE_Article
group by substring(Content,1,4000),ChannelID,ClassID,Title
having count(*)> =2 and ChannelID= '1035 '
------解决方案--------------------
select a.Content,b.* from PE_Article a,(
select ChannelID,ClassID,Title,count(*) aou from PE_Article
group by Content,ChannelID,ClassID,Title
having count(*)> =2 and ChannelID= '1035 ')
where a.ChannelID=b.ChannelID
------解决方案--------------------
--try


select a.Content,b.* from PE_Article a,(
select ChannelID,ClassID,Title,count(*) aou from PE_Article
group by Content,ChannelID,ClassID,Title
having count(*)> =2 and ChannelID= '1035 ') b
where a.ChannelID=b.ChannelID

------解决方案--------------------
text,ntext,image类型的列不能用于group by.
------解决方案--------------------
select Content=cast(Content as varchar),ChannelID,ClassID,Title,count(*) from PE_Article
group by cast(Content as varchar),ChannelID,ClassID,Title
having count(*)> =2 and ChannelID= '1035 '