我有以下数据
Pet xVal
Cat 1
Cat 7
Cat 9
Dog 2
Dog 3
Dog 4是否可以返回附加列中每个数据集的最高值?所以上面的数据,预期输出是:-
Pet xVal Largest
Cat 1 9
Cat 7 9
Cat 9 9
Dog 2 4
Dog 3 4
Dog 4 4发布于 2018-02-08 10:37:59
这可以使用窗口函数来完成:
select pet, xval, max(xval) over (partition by pet) as largest
from the_table;https://stackoverflow.com/questions/48683387
复制相似问题