Based on two answers, I managed to get the following:
SET @counter = 0; Select sub.orderid,sub.value,(@counter := @counter +1) as counter FROM ( select orderid, round(sum(unitprice * quantity),2) as value from order_details group by orderid ) sub order by 2 desc limit 10
The original responses showed identifiers from the internal query, resulting in large indexes with large spaces. Using the modification, I get only the range from 1 to x, which I need for my pgfplots LaTeX chart.
source share