SQL Server 2008 查询中按错误分组
我有这个查询:
select row_number() over(order by Name) as Number,Name
,COUNT(Code) as Tqty from WorkTbl group by Name order by Tqty
,COUNT(Code) as Tqty2 from WorkTbl Where Status <> 'AA' and Status <> 'BB' group by Name order by Tqty2
并且收到错误:
关键字“as”附近的语法不正确。
但如果我运行此查询,它工作正常:
select row_number() over(order by Name) as Number,Name
,COUNT(Code) as Tqty from WorkTbl group by Name order by Tqty
我必须拥有查询中的所有列
如何做到这一点?
I have this query:
select row_number() over(order by Name) as Number,Name
,COUNT(Code) as Tqty from WorkTbl group by Name order by Tqty
,COUNT(Code) as Tqty2 from WorkTbl Where Status <> 'AA' and Status <> 'BB' group by Name order by Tqty2
and I get an error:
Incorrect syntax near the keyword 'as'.
but if I run this query it works fine:
select row_number() over(order by Name) as Number,Name
,COUNT(Code) as Tqty from WorkTbl group by Name order by Tqty
I must have all columns in the query
How to do it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可能需要类似的东西
You probably need something like