MySQL Count和sort增强查询 [英] MySQL Count and sort enhance query

查看:78
本文介绍了MySQL Count和sort增强查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下查询,但对我而言,我一生都无法找出按最大计数排序的正确语法,仅包含5或更高的计数.基本上,我只想显示COUNT个办公室中有5个或5个以上Office的结果,然后按照数量最多的Office进行排序?

I am using the following query but for the life of me can't figure out the proper syntax to sort by the largest count and only include a count of 5 or higher. Basically I only want to display results that have 5 or more Offices in the COUNT and then sort by those with the largest count first?

SELECT COUNT(Offices) FROM Active GROUP BY Offices

推荐答案

SELECT COUNT(Offices) AS c FROM Active GROUP BY Offices HAVING COUNT(Offices) >= 5  ORDER BY c DESC

这篇关于MySQL Count和sort增强查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆