Teradata SQL找出季度最高薪水 [英] Teradata SQL to find out quarterly highest salary

查看:122
本文介绍了Teradata SQL找出季度最高薪水的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的输入数据,其中包含员工ID,工资月和工资:



Emp Id月工资

1月1日1000

2月3000年

2000年1月3日

2000年2月1日

2月3000日

3月2日5000

2000年3月1日
3月3日3000

3月4000

4月1日4000

4月6000

2000年4月3日

5月3000

2000年5月2日
3月1000日

1月6日3000

2000年6月2日

3月1000日



我希望季度最高工资以及月份和员工ID如下:



Emp Id月工资

3月5日5000

2月6000



员工3在第二季度获得最高薪水

员工2在第二季度获得最高薪水在第二季度



我有什么尝试过:



................

.... ........

.........

................. ...................................

解决方案

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



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

这并不复杂:你只需要在该季度进行GROUP BY,然后找到每个组的MAX值并将JOIN返回到原始表。这可能有所帮助: SQL GROUP By和列'名称'在选择列表中无效,因为......错误 [ ^ ] - 它不会给你解决方案,但它可以解释你需要什么学习。



如果您遇到特定问题,请询问相关问题,我们会尽力提供帮助。但我们不打算为你做这一切!


I have the input data like below which is having employee id,month of salary and the salary:

Emp Id Month Salary
1 January 1000
2 January 3000
3 January 2000
1 February 2000
2 February 3000
3 February 5000
1 March 2000
2 March 3000
3 March 4000
1 April 4000
2 April 6000
3 April 2000
1 May 3000
2 May 2000
3 May 1000
1 June 3000
2 June 2000
3 June 1000

I want to have quarterly highest salary along with month and employee id like below:

Emp Id Month Salary
3 February 5000
2 April 6000

As Employee 3 is getting highest salary in february month for first quarter
Employee 2 is gettingg highest salary in april month for second quarter

What I have tried:

................
............
.........
....................................................

解决方案

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!
This isn't complicated: you just need to GROUP BY the quarter, then find the MAX value for each group and JOIN that back to the original table. This may help: SQL GROUP By and the "Column 'name' is invalid in the select list because..." error[^] - it won't give you the solution, but it may explain what you need to learn.

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


这篇关于Teradata SQL找出季度最高薪水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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