从db计数中获取组中的组 [英] Fetching in groups from db on count
本文介绍了从db计数中获取组中的组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用group by从群组中获取数据。
群组可以有任意数量的记录。
我只想要前20个这样的群组。
类似于: -
从表中选择前20名
其中条件
group by someId,someOtherId。
I want to fetch data from db in groups using group by.
Group can have any number of records.
I want only top 20 of such groups.
Something like:-
select top 20 from table
where conditions
group by someId, someOtherId.
推荐答案
你差不多完成了。
You almost done.
SELECT TOP 20 SomeColumn,COUNT(SomeOtherColumn) AS SomeOtherColumn_Count FROM Table_Name
GROUP BY SomeColumn;
FYI TOP [ ^ ]& GROUP BY [ ^ ] @ www.w3schools.com [ ^ ]
FYI TOP[^] & GROUP BY[^] @ www.w3schools.com[^]
这篇关于从db计数中获取组中的组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文