Click here to Skip to main content
15,880,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
phil.o 23-Nov-15 7:33am    
And what have you tried?
Aviinash 23-Nov-15 7:46am    
i have tried both max and groupby but its not working pls help
phil.o 23-Nov-15 7:51am    
Please show your query. 'is not working' is not a valid issue description.
Kornfeld Eliyahu Peter 23-Nov-15 7:36am    
MAX and GROUP BY
Aviinash 23-Nov-15 7:46am    
i have tried both max and groupby but its not working pls help

As Peter pointed out, this is rather easy and a good activity for you to learn. Follow this example:

SQL
SELECT MAX(field1), field2
FROM table1 
GROUP BY field2


This will find the biggest field1 for each field2 since we told it to group field2 together.
 
Share this answer
 
Comments
Arasappan 23-Nov-15 8:06am    
5
SQL
select distinct  a.NAme,max(a.salary) as salary from table_name a group by NAme order by salary desc


SQL
select distinct  a.NAme,max(a.salary) as salary from table_name a group by NAme
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900