如何找到各部门员工的最高工资? [英] How to find the max salary of employee of each department ?

查看:119
本文介绍了如何找到各部门员工的最高工资?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表格如下:



Emp:empid,age,empname



部门:depid ,depname,empid



删除了SHOUTING - OriginalGriff [/ edit]

Table are as follows:

Emp: empid,age ,empname

Dept: depid, depname,empid

[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

1)我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



2)正如我所说:不要大喊大叫。即使我倾向于帮助你,我也不会 - 因为你故意粗鲁地开始谈话。
1) We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

2) As I said: DON'T SHOUT. Even if I was inclined to help you, I wouldn't have - because you started the conversation by being deliberately rude.


读取:

SQL GROUP BY语句 [ ^ ]

SQL MAX()功能 [ ^ ]

SQL INNER JOIN [ ^ ]



示例sql查询(我假设你在emp表中有薪水)

read :
SQL GROUP BY Statement[^]
SQL MAX() Function[^]
SQL INNER JOIN [^]

sample sql query (I assume you have salary in emp table)
SELECT MAX(E.SALARY), D.DEPNAME FROM EMP E
JOIN DEPT D ON E.EMPID = D.EMPID
GROUP BY D.DEPNAME


到目前为止你尝试了什么?



和寻找在表结构中,我甚至找不到薪水栏本身。所以,你怎么知道薪水是多少。



目前的表结构甚至没有标准化。

无论如何,如果我是你我会先将表重组为:



What have you tried so far?

And looking at the Table structure, I don't even find the salary column itself. So, how do you know what the Salary is.

The current table structure is not even normalised.
Anyway, if I were you I would first restructure the tables as:

Employee:
	Id,
	Name,
	Age,
	Salary,
	DepartmentId







Department:
	Id,
	Name





除此之外,我建议你在SQL中查看以下主题(至少):



MAX



http://www.w3schools.com/sql/sql_join.asp [ ^ ]



GroupBy



http://www.w3schools.com/sql/sql_groupby.asp [ ^ ]



加入



http://www.w3schools.com/sql/sql_join.asp [ ^ ]



我建议你自己写一下,然后告诉我们你尝试了什么。如果你还有问题,这里有人会帮助你。



Apart from that I would suggest you to look at following topics (atleast) in SQL:

MAX

http://www.w3schools.com/sql/sql_join.asp[^]

GroupBy

http://www.w3schools.com/sql/sql_groupby.asp[^]

Joins

http://www.w3schools.com/sql/sql_join.asp[^]

I suggest you try it out writing yourself and show us what have you tried. And if you still have questions, someone here would help you.


这篇关于如何找到各部门员工的最高工资?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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