如何使用子查询或其他东西获取DATA [英] How to get DATA using subquery or other thing
问题描述
我有一张桌子,其中的数据就像名字一样,但同一个员工的薪水不同但是我找到了一张桌子里所有员工的最高工资
例如
NAme |工资
AVinash | 100
AVinash | 110
AVinash | 120
阿卡什| 100
阿卡什| 110
阿卡什| 120
Somesh | 100
AVinash | 110 >
AVinash | 120
现在我需要像
这样的桌子
工资
Avinash | 120
Akash | 120
somesh | 120
I am having table in which the data is like name is same but the salary is different for that same sme employee but i have find the max salary of all employee in one table
eg
NAme |salary
AVinash |100
AVinash |110
AVinash |120
Akash |100
Akash |110
Akash |120
Somesh |100
AVinash |110
AVinash |120
Now i need table like
Name | Salary
Avinash|120
Akash |120
somesh |120
推荐答案
正如彼得所指出的,这对你来说相当容易,也是一项很好的活动。请遵循以下示例:
As Peter pointed out, this is rather easy and a good activity for you to learn. Follow this example:
SELECT MAX(field1), field2
FROM table1
GROUP BY field2
这将为每个field2找到最大的field1,因为我们告诉它将field2组合在一起。
This will find the biggest field1 for each field2 since we told it to group field2 together.
select distinct a.NAme,max(a.salary) as salary from table_name a group by NAme order by salary desc
select distinct a.NAme,max(a.salary) as salary from table_name a group by NAme
这篇关于如何使用子查询或其他东西获取DATA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!