gpt4 book ai didi

sql-server - 每月总销售额

转载 作者:行者123 更新时间:2023-12-02 06:23:11 28 4
gpt4 key购买 nike

如果您有一个包含 SALES {Customer_ID, Price, SmallDateTime 日期} 的表。您如何报告每月的所有销售额?

SELECT Sum(Price) As Total Sales FROM SALES Group By What Having What 

最佳答案

  SELECT YEAR(date) as SalesYear,
MONTH(date) as SalesMonth,
SUM(Price) AS TotalSales
FROM Sales
GROUP BY YEAR(date), MONTH(date)
ORDER BY YEAR(date), MONTH(date)

关于sql-server - 每月总销售额,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5984738/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com