MYSQL - SUM of a column based on common value in other column

前端 未结 3 1965
日久生厌
日久生厌 2021-01-29 01:52

I\'m stuck on crafting a MySQL query to solve a problem. I\'m trying to iterate through a list of \"sales\" where I\'m trying to sort the Customer IDs listed by their total accu

3条回答
  •  清酒与你
    2021-01-29 01:56

    You need to GROUP BY your customer id:

    SELECT CustomerID, SUM(PurchasePrice) AS PurchaseTotal
    FROM sales
    GROUP BY CustomerID;
    

提交回复
热议问题