SQL的最大数量和计数 [英] Max number and count from SQL
本文介绍了SQL的最大数量和计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Name Project
Sujata abcd.com
Sujata ghj.com
Sujata lok.com
Rishi k.com
Rishi l.com
Ram ol.com
Ram ui.com
Ram p.com
Ram lp.com
** Need a query who has maximum number of project
什么我试过了:
What I have tried:
Name Project
Sujata abcd.com
Sujata ghj.com
Sujata lok.com
Rishi k.com
Rishi l.com
Ram ol.com
Ram ui.com
Ram p.com
Ram lp.com
** Need a query who has maximum number of project
推荐答案
这个想法是按每个名字计算项目数量(group by ),按降序排序(按desc排序),然后选择前1,试试这个:
This idea will be to count the number of project by each name (group by), sort them by the count in descending order (order by desc), then pick the top 1, try this:
select top 1 name, count(project) from projecttable group by name order by count(project) desc
这篇关于SQL的最大数量和计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文