销售统计SQL - 911 - 博客园
---每日销售数量(不含运费)
select a.date as '日期',sum(a.je) as '销售额'  from (select (productnum*paid) as je,convert(varchar(100),orders.act_time5,23)  as date from orders where state=5
and act_time5>='2010-02-12 00:01' and act_time5<='2010-02-21 23:59'
union
select (productnum*paid) as je,convert(varchar(100),orders_err.act_time5,23)  as date from orders_err where state=5
and act_time5>='2010-02-12 00:01' and act_time5<='2010-02-21 23:59') as a group by a.date order by a.date asc
---查询订单数
select a.date as '日期',count(a.goods) as '订单数'  from (select distinct goods,convert(varchar(100),orders.act_time5,23)  as date from orders where state=5
and act_time5>='2010-02-12 00:01' and act_time5<='2010-02-21 23:59'
union
select distinct goods,convert(varchar(100),orders_err.act_time5,23)  as date from orders_err where state=5
and act_time5>='2010-02-12 00:01' and act_time5<='2010-02-21 23:59') as a group by a.date order by a.date asc
---每日销售额(只算运费)
select a.date as '日期',sum(a.je) as '销售额'  from (select distinct goods,actfee as je,convert(varchar(100),orders.act_time5,23)  as date from orders where state=5
and act_time5>='2010-02-12 00:01' and act_time5<='2010-02-21 23:59'
union
select distinct goods,actfee as je,convert(varchar(100),orders_err.act_time5,23)  as date from orders_err where state=5
and act_time5>='2010-02-12 00:01' and act_time5<='2010-02-21 23:59') as a group by a.date order by a.date asc

郑重声明:资讯 【销售统计SQL - 911 - 博客园】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——