Reputation: 886
I have the following data
Pet xVal
Cat 1
Cat 7
Cat 9
Dog 2
Dog 3
Dog 4
Is it possible to to return the highest value for each data set in an additional column? So the the data above, the expect output would be :-
Pet xVal Largest
Cat 1 9
Cat 7 9
Cat 9 9
Dog 2 4
Dog 3 4
Dog 4 4
Upvotes: 0
Views: 38
Reputation:
This can be done using window functions:
select pet, xval, max(xval) over (partition by pet) as largest
from the_table;
Upvotes: 5