先用context by与limit一起使用获取表中每个分组前n条记录或最后n条记录。
```
select * from t context by bb limit -1
```
然后用atImax找出排名最大值所在的位置,然后返回bb中该位置对应的值
```
exec atImax(aa,bb) from (select * from t context by bb limit -1)
```
示例代码如下:
```
t=table(5 2 1 4 as aa,`a`b`a`b as bb)
select * from t where bb=exec atImax(aa,bb) from (select * from t context by bb limit -1)
```