sql 语句 高手来看

symbol_bc 2009-09-17 11:53:59
select col1,col2,col3,count(*) as [count]
from @temp
group by col1,col2,col3 having [count] > 1
总说[count] 不能识别


请问应该怎样写
...全文
125 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzxap 2009-09-17
  • 打赏
  • 举报
回复
select id,count(name) as asd from t2 group by id having count(name)>2

不能使用别名的,记错了
zzxap 2009-09-17
  • 打赏
  • 举报
回复
可以使用别名的
阿非 2009-09-17
  • 打赏
  • 举报
回复


declare @t table(
name varchar(10)
)
insert into @t select '1'
insert into @t select '2'
insert into @t select '3'
insert into @t select '4'
insert into @t select '4'
select * from @t
select name from @t group by name
--select name n from @t group by n
select * from (select name n from @t) t group by n
select name,[COUNT] from (select name,COUNT(*) [count] from @t group by name) t group by name,[count] having [count]>1
hzj170 2009-09-17
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 lixinramaxel41658133 的回复:]
C# codeselect col1,col2,col3,count(*)as [count]from @tempgroupby col1,col2,col3 having count(*)>1
[/Quote]
这样应该可以。。
jack15850798154 2009-09-17
  • 打赏
  • 举报
回复
把Count换成别的别名不就行了吗?
hassy070123 2009-09-17
  • 打赏
  • 举报
回复
good!!!!!
沉序员 2009-09-17
  • 打赏
  • 举报
回复
gggggggggggggggggg
阿非 2009-09-17
  • 打赏
  • 举报
回复
和你之前问的问题是一样的,不能使用别名


select col1,col2,col3,count(*)
from @temp
group by col1,col2,col3 having count(*) > 1


tel15928316795 2009-09-17
  • 打赏
  • 举报
回复
应该是count(*)才对因为是统计的条数嘛
  • 打赏
  • 举报
回复

select col1,col2,col3,count(*) as [count]
from @temp
group by col1,col2,col3 having count(*) > 1
tel15928316795 2009-09-17
  • 打赏
  • 举报
回复
应该是count(*)才对因为是统计的条数嘛
  • 打赏
  • 举报
回复

select col1,col2,col3,count(*) as [count]
from @temp
group by col1,col2,col3 having count(*) > 1
wujinjian2008n 2009-09-17
  • 打赏
  • 举报
回复

select col1,col2,col3,count(*) as [count]
from @temp
group by col1,col2,col3 having count(*) > 1

  • 打赏
  • 举报
回复

select CorporateNo,count(*) from LMS_Centerlist
group by CorporateNo having count(*)>1
fluat 2009-09-17
  • 打赏
  • 举报
回复
count是关键字啊
Aderlee 2009-09-17
  • 打赏
  • 举报
回复
因为[count]不属于@temp

select A.* from
(select col1,col2,col3,count(*) as [count]
from @temp
group by col1,col2,col3) A where [count] > 1
imfor 2009-09-17
  • 打赏
  • 举报
回复
count 是关键字 换成别的就可以了

[code=VB]select col1,col2,col3,count(*) as [ALLcount]
from @temp
group by col1,col2,col3 having [ALLcount] > 1
[/code]

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧