sql 语句实现根据日期字段计算总营业额的查询

标签: sql  sms

1.实例:

	<!-- 计算每天营业总额 -->
	<select id="getDayPay" resultType="Customer">
		select check_out, sum(pay) sum  from customer group by check_out
	</select>
	<!-- 计算每月营业总额 -->
	<select id="getMonthPay" resultType="Customer">
		select check_out, sum(pay) sum  from customer group by month(check_out) order by check_out
	</select>
	
	<!-- 计算每年营业总额 -->
	<select id="getYearPay" resultType="Customer">
		select check_out, sum(pay) sum  from customer group by year(check_out) order by check_out
	</select>

2.对每条数据到数据库中测试的结果:



版权声明:本文为qq_28316183原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_28316183/article/details/78132765