首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

[疑难杂证]求救解决方案

2012-01-19 
[疑难杂证]求救我原来的句子是这样的,可以运行.selectChannelID,ClassID,Title,count(*)fromPE_Articlegro

[疑难杂证]求救
我原来的句子是这样的,可以运行.
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 '

热点排行