销售统计SQL
---每日銷售數量(不含運費)
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
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
轉載于:https://www.cnblogs.com/911/archive/2010/02/22/1670906.html
總結
- 上一篇: Java论坛系统 JForum
- 下一篇: asp.net DBHelper类