这是我的剧本
SELECT COUNT( [Id]) as [Count Of Register],
Tag as [Tag]
FROM [Members]
Group By Tag
Order By [Count Of Register] Desc;
返回的表是这样的:
Count Tag
550 ----1
550 ----2
545 ----3
545 ----4
545 ----5
所以,这次我需要标签计数,按这个新的计数字段分组.
So, this time I need Count of Tag, Group by this new Count field.
一些返回值如:
2 ---550
3 ---545
有什么办法可以不使用新表或模板表或任何存储表,仅通过查询?
Is there any way without using new table or Template Table or any Storage Table just by query?
SELECT [Count Of Register], COUNT(1) [Grouped Count]
FROM
(
SELECT COUNT( [Id]) as [Count Of Register],
Tag as [Tag]
FROM [Members]
Group By Tag
) MyTable
GROUP BY [Count Of Register]
这篇关于按计数计数的 SQL 组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!