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

前端 未结 3 1967
日久生厌
日久生厌 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 02:01

    Just by having a little Google search, I managed to find a page doing exactly what you're doing (I think). I have tailored the query below to fit your circumstance.

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

    Link to Page with Tutorial on SQL Groups

提交回复
热议问题