每月总销售额

时间:2022-11-24
本文介绍了每月总销售额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您有一个带有 SALES {Customer_ID, Price, SmallDateTime date} 的表格.您如何报告每月的所有销售额?

If you have a table with SALES {Customer_ID, Price, SmallDateTime date}. How do you report all sales per month?

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)

这篇关于每月总销售额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:将 SQL Server DateTime 列迁移到 DateTimeOffset 下一篇:从存储过程中检测脏读

相关文章

最新文章