Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Incluir um contador adicional no conjunto de resultados do MySQL


Tente isto:
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