zoukankan      html  css  js  c++  java
  • 销售统计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

  • 相关阅读:
    C# 读取本地图片 转存到其他盘符
    Sql server之路 (六)上传服务器图片
    wp8 ListPicker
    Sql server之路 (五)插入多条数据
    Wcf for wp8 调试Wcf服务程序(四)
    win8 鼠标失灵解决办法
    Sql server之路 (一)基础学习
    Caché开发环境介绍
    Cache数据库简介
    MYSQL之sql优化——慢查询日志
  • 原文地址:https://www.cnblogs.com/911/p/1670906.html
Copyright © 2011-2022 走看看