Im struggling with removing duplicate values within certain employee ID. Here is the situation:
ID || VALUE1 || VALUE2 || DATE
11 || Position1 || Other1 || 2019-04-04
11 || Position2 || Other3 || 2019-05-04
11 || Position1 || Other1 || 2019-06-04
12 || Position2 || Other3 || 2019-01-04
12 || Position1 || Other1 || 2019-03-04
12 || Position2 || Other3 || 2019-04-04
12 || Position3 || Other1 || 2019-05-04
13 || Position1 || Other3 || 2019-04-04
13 || Position3 || Other1 || 2019-05-04
13 || Position1 || Other3 || 2019-06-04
What I want to do is to remove repeating values for column VALUE1 but only within certain ID and the value which stays is the newest. So the results can look like:
ID || VALUE1 || VALUE2 || DATE
11 || Position2 || Other3 || 2019-05-04
11 || Position1 || Other1 || 2019-06-04
12 || Position1 || Other1 || 2019-03-04
12 || Position2 || Other3 || 2019-04-04
12 || Position3 || Other1 || 2019-05-04
13 || Position3 || Other1 || 2019-05-04
13 || Position1 || Other3 || 2019-06-04
I dont know how to achieve that using partition by or distinct. Any advices?
Best Answer
Perhaps something like this?