Hãy thử điều này:
SET @counter = 0;
Select sub.*
FROM
(
select orderid, (@counter := @counter +1) as counter,
round(sum(unitprice * quantity),2) as value
from order_details
group by orderid
) sub
order by 2 desc
Hãy thử điều này:
SET @counter = 0;
Select sub.*
FROM
(
select orderid, (@counter := @counter +1) as counter,
round(sum(unitprice * quantity),2) as value
from order_details
group by orderid
) sub
order by 2 desc