Skip to content
Advertisement

I want to get the updated Salary by EmpID

I have a column EmpID and Salary. I want to get the updated salary each EmpID.

FIGURE 1 :

ID EMPID Salary
1 00000 75000
2 00000 80000
3 00001 75000
4 00001 90000
5 00001 91000
6 00010 50000
7 00010 60000
8 00010 70000

This is my initial query that I created with specific EMPID 00000 :

The output that I get is still the same as Figure 1.

The output must be in distinct in EmpID with the updated salary.

FIGURE 2 :

ID EMPID Salary
1 00000 80000
2 00001 91000
3 00010 70000

Advertisement

Answer

what are you looking for can be achieved by group by as follows, however chosing your desired ID remain issue but it has been acheived by row_number

in addition you can use Row_number and Sub-query in order to distinguish new changes.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement