Como sugestão para encontrar uma solução para obter as 3 primeiras entradas por nome de usuário,
talvez seja necessário seguir vários passos sem usar a expressão de janela.
O código pode parecer assim:
select appid, uname, count(*) as total
from zusage
group by appid, uname
order by appid, total descending
into corresponding fields of table @lt_all_usage.
select appid, max(total)
from @lt_all_usage.
group by appid
into table @lt_app_max
do 3 times.
select a~appid, a~uname, a~total
from @lt_all_usage as a
where
inner join @lt_app_max as b
on b~appid = a~appid and b~total = a~total
appending into table @lt_result
select a~appid, max(a~total)
from @lt_all_usage as a
inner join @lt_app_max as b
on a~appid = b~appid
and a~total < b~total
group by a~appid
into table @lt_app_max
endo.
sort lt_result by appid.
r