龙空技术网

mysql统计语句望大神指导 统计每天的数据如下

全能男子 112

前言:

如今咱们对“mysql判断一天”可能比较注重,小伙伴们都需要学习一些“mysql判断一天”的相关内容。那么小编在网络上汇集了一些有关“mysql判断一天””的相关内容,希望咱们能喜欢,咱们一起来学习一下吧!

SELECT	days dateTime,	sum( sales_num ) salesNum,	sum( sales_price ) salesPrice,	sum( purchase_cost_price ) purchaseCostPrice,	sum(sales_price-purchase_cost_price) groessPrice,	sum(groess_price/sales_num) ugPrice,	sum(groess_price/sales_price) ugRate,	sum(total_personnel_price) totalPersonnelPrice,	sum(total_loss_price) totalLossPrice,	sum(cost_total_price) costTotalPrice,	sum(total_price) totalPrice,	sum(fine_price) finePrice,	sum(logistics_cost_price) logisticsCostPrice,	sum(total_personnel_price+cost_total_price++fine_price+logistics_cost_price+500) totalCost,	sum(groess_price-(total_personnel_price+cost_total_price++fine_price+logistics_cost_price)-500) ratePrice,	sum((groess_price-(total_personnel_price+cost_total_price++fine_price+logistics_cost_price)-500)/sales_num) rateNum,	sum((groess_price-(total_personnel_price+cost_total_price++fine_price+logistics_cost_price)-500)/sales_price) rateNumPriceFROM	(SELECT	DATE_FORMAT( create_time, '%Y-%m-%d' ) days,	sum( sales_num ) sales_num,	sum( sales_price ) sales_price,	sum( purchase_cost_price ) purchase_cost_price,	sum(sales_price-purchase_cost_price) groess_price,	0 total_personnel_price,	0 total_loss_price,	0 cost_total_price,	0	total_price,	0 fine_price,	0 logistics_cost_priceFROM	fty_sales_report GROUP BY	days UNION ALLSELECT	DATE_FORMAT( create_time, '%Y-%m-%d' ) days,	0 sales_num,	0 sales_price,	0 purchase_cost_price,	0 groess_price,	sum(total_personnel_price) total_personnel_price,	sum(total_loss_price) total_loss_price,	0 cost_total_price,	0 total_price,	0 fine_price,	0 logistics_cost_priceFROM	fty_production_daily GROUP BY	days 	UNION ALLSELECT	DATE_FORMAT( create_time, '%Y-%m-%d' ) days,	0 sales_num,	0 sales_price,	0 purchase_cost_price,	0 groess_price,	0 total_personnel_price,	0 total_loss_price,	sum(cost_total_price) cost_total_price,	0 total_price,	0 fine_price,	0 logistics_cost_priceFROM	fty_deliver_cost GROUP BY	days 	UNION ALLSELECT	DATE_FORMAT( create_time, '%Y-%m-%d' ) days,	0 sales_num,	0 sales_price,	0 purchase_cost_price,	0 groess_price,	0 total_personnel_price,	0 total_loss_price,	0 cost_total_price,	sum(total_price) 	total_price,	0 fine_price,	0 logistics_cost_priceFROM	fty_platform_return GROUP BY	days 	UNION ALLSELECT	DATE_FORMAT( create_time, '%Y-%m-%d' ) days,	0 sales_num,	0 sales_price,	0 purchase_cost_price,	0 groess_price,	0 total_personnel_price,	0 total_loss_price,	0 cost_total_price,	0	total_price,	sum(fine_price) fine_price,	0 logistics_cost_priceFROM	fty_platform_fine GROUP BY	days 	UNION ALLSELECT	DATE_FORMAT( create_time, '%Y-%m-%d' ) days,	0 sales_num,	0 sales_price,	0 purchase_cost_price,	0 groess_price,	0 total_personnel_price,	0 total_loss_price,	0 cost_total_price,	0	total_price,	0 fine_price,	sum(cost_total_price) logistics_cost_priceFROM	fty_logistics_cost GROUP BY	days 	) a GROUP BY	days

还有其他写法吗 感觉这样写不是很好

标签: #mysql判断一天