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

GROUP BY lname ORDER BY mostrando resultados errados


Tente usar um padrão ANSI adequado, GROUP BY
SELECT
    u.fname, u.lname, SUM(p.point) as points
FROM 
    comp_sale s
    JOIN
    comp_product p ON s.prod_id = p.product_id 
    JOIN
    comp_user u ON s.sale_id = u.wp_id
GROUP BY
    u.fname, u.lname
ORDER BY 
    points DESC 
LIMIT 25

Além disso, use JOINs explícitos para maior clareza