如何解决要求“最多"的问题? [英] How do i solve a question asking for 'Most' ?

查看:81
本文介绍了如何解决要求“最多"的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要写一个查询来选择雇用大多数员工的年份,该年份以及员工人数.我该怎么做?

I need to write a query to select the year in which most of the employees were hired, that year and the number of employees. How do i do this?

推荐答案

绝对不知道您的数据库结构是什么样子,我将不得不猜测....但是一个GROUP和COUNT会起作用.

With aboslutely no idea what your database structure looks like, I''ll have to guess....but a GROUP and COUNT will work.

SELECT
     Year(EmployeeStartDate) AS YearHired, COUNT(EmployeeId) AS EmployeeHiredCount
FROM
    EmployeeDetails
GROUP BY
    Year(EmployeeStartDate)
ORDER BY 
    Count(EmployeeID) DESC




假设您有一个包含员工详细信息的表并始终记录其开始日期,则可以使用YEAR函数对该字段进行分组和计数.看看您是否能找到如何选择自己感兴趣的记录.




Assuming you''ve got a table with Employee details and always record their start date, you can use the YEAR function to group and count by that field. See if you can figure out how to select the record you''re interested in.


这篇关于如何解决要求“最多"的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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