在销售方面找到最优秀的员工。 [英] Find the top employees in terms of sales.
本文介绍了在销售方面找到最优秀的员工。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要在销售方面找到最优秀的员工,但我无法获得足够的产出
我尝试过:
在e.e_id = s.e_id group中按员工e加盟销售选择e_name by sale_id limit 1;
解决方案
您需要对查询进行排序以将最高值带到顶部 - 提示:按降序排列。
参考: MySQL :: MySQL 8.0参考手册:: 8.2.1.14 ORDER BY优化 [ ^ ]
只是添加到CHill60所说的内容:您需要ORDER BY销售,但是因为您正在使用GROUP BY,你还需要查看一个合适的聚合函数。
看看这里: [ ^ ]因为这是咬你的下一件事 - 它是基于SQL Server但是MySql的原理是相同的
in need to find the top employee in terms of sales but i am not able to get sufficient output
What I have tried:
select e_name from employee e join sale s on e.e_id=s.e_id group by sale_id limit 1;解决方案You need to ORDER your query to bring the top value to the "top" - hint: in descending order.
Reference: MySQL :: MySQL 8.0 Reference Manual :: 8.2.1.14 ORDER BY Optimization[^]
Just to add to what CHill60 says: you need to ORDER BY sales, but since you are using GROUP BY, you will also need to look at an appropriate aggregate function.
Have a look here: SQL GROUP By and the "Column 'name' is invalid in the select list because..." error[^] as that's the next thing that will bite you - it's SQL Server based but the principles are the same for MySql
这篇关于在销售方面找到最优秀的员工。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文