why does this give me the wrong customerNumber?

后端 未结 3 1231
南方客
南方客 2021-01-26 05:29

I tried to get the customer that pay the maximum amount. It gave me the maximum amount but the wrong customer. what should i do?

SELECT temp.customerNumber, MAX         


        
3条回答
  •  不思量自难忘°
    2021-01-26 06:01

    I don't think you need the Subquery here:

    SELECT p.customerNumber, MAX(p.amount) AS max
    FROM payments p
    GROUP BY p.customerNumber
    ORDER BY max DESC
    LIMIT 1
    

提交回复
热议问题