半年的月销售报表
月份 1月 2月 3月 4月 5月 6月
洗发水 单价 ¥36 ¥35 ¥33 ¥24 ¥30 ¥30
销售量 300 231 230 151 352 123
洗发水月销售额 ¥10,800  ¥8,085  ¥7,590  ¥3,624  ¥10,560  ¥3,690 
沐浴露 单价 ¥28 ¥29 ¥35 ¥28 ¥29 ¥28
销售量 400 335 250 321 325 243
沐浴露月销售额 ¥11,200  ¥9,715  ¥8,750  ¥8,988  ¥9,425  ¥6,804 
洗面奶 单价 ¥54 ¥46 ¥34 ¥50 ¥46 ¥56
销售量 350 204 340 250 345 198
洗面奶月销售额 ¥18,900  ¥9,384  ¥11,560  ¥12,500  ¥15,870  ¥11,088 
香皂 单价 ¥8 ¥6 ¥5 ¥8 ¥6 ¥7
销售量 344 431 300 261 172 195
香皂月销售额 ¥2,580  ¥2,586  ¥1,500  ¥1,958  ¥1,032  ¥1,365 
月销售总额 ¥43,480  ¥29,770  ¥29,400  ¥27,070  ¥36,887  ¥22,947  各个商品的月销售额是单价*销售量
 月销售总额是当月个产品销售额的总和

解决方案 »

  1.   

    我有三个表
    产品信息表productinfo(proid,proname)
    订单表orders(orid,empid,ordertime)
    订单子表orderinfo(id,orid,proid,orsale,ornum)
      

  2.   

    最好给出完整的表结构,测试数据,计算方法和正确结果.发帖注意事项
    http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281
      

  3.   

    你的这个问题并不难,先把产品信息表,订单表,订单子表这三个表建成一个视图联起来。
    select 产品名称,'数量' as ctype,sum(case when month(销售日期)=1 then 销售数量 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售数量 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售数量 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售数量 else 0 end) as m4 from 视图 group by 产品名称
    union all 
    select 产品名称,'金额' as ctype,sum(case when month(销售日期)=1 then 销售金额 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售金额 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售金额 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售金额 else 0 end) as m4 from 视图 group by 产品名称
    order by 产品名称方法就这样的了。其它根据自己需要自己变一下就好。
      

  4.   

    你的这个问题并不难,先把产品信息表,订单表,订单子表这三个表建成一个视图联起来。
    select 产品名称,'数量' as ctype,sum(case when month(销售日期)=1 then 销售数量 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售数量 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售数量 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售数量 else 0 end) as m4 from 视图 group by 产品名称
    union all  
    select 产品名称,'金额' as ctype,sum(case when month(销售日期)=1 then 销售金额 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售金额 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售金额 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售金额 else 0 end) as m4 from 视图 group by 产品名称
    order by 产品名称方法就这样的了。其它根据自己需要自己变一下就好。 
     
     
    对我有用[0] 丢个板砖[0] 引用 举报 管理 TOP  
    管理菜单 生成帖子 置顶 推荐 取消推荐 锁定 解锁 移动 编辑 删除 帖子加分 帖子高亮 取消高亮  
    结  帖 发  帖 回  复 
      

  5.   

    你的这个问题并不难,先把产品信息表,订单表,订单子表这三个表建成一个视图联起来。
    select 产品名称,'数量' as ctype,sum(case when month(销售日期)=1 then 销售数量 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售数量 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售数量 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售数量 else 0 end) as m4 from 视图 group by 产品名称
    union all  
    select 产品名称,'金额' as ctype,sum(case when month(销售日期)=1 then 销售金额 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售金额 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售金额 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售金额 else 0 end) as m4 from 视图 group by 产品名称
    order by 产品名称方法就这样的了。其它根据自己需要自己变一下就好。 
     
     
    对我有用[0] 丢个板砖[0] 引用 举报 管理 TOP  
    管理菜单 生成帖子 置顶 推荐 取消推荐 锁定 解锁 移动 编辑 删除 帖子加分 帖子高亮 取消高亮  
    结  帖 发  帖 回  复 
      

  6.   

    你的这个问题并不难,先把产品信息表,订单表,订单子表这三个表建成一个视图联起来。
    select 产品名称,'数量' as ctype,sum(case when month(销售日期)=1 then 销售数量 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售数量 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售数量 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售数量 else 0 end) as m4 from 视图 group by 产品名称
    union all  
    select 产品名称,'金额' as ctype,sum(case when month(销售日期)=1 then 销售金额 else 0 end) as m1,sum(case when month(销售日期)=2 then 销售金额 else 0 end) as m2,sum(case when month(销售日期)=3 then 销售金额 else 0 end) as m3,sum(case when month(销售日期)=4 then 销售金额 else 0 end) as m4 from 视图 group by 产品名称
    order by 产品名称方法就这样的了。其它根据自己需要自己变一下就好。 
     
     
    对我有用[0] 丢个板砖[0] 引用 举报 管理 TOP  
    管理菜单 生成帖子 置顶 推荐 取消推荐 锁定 解锁 移动 编辑 删除 帖子加分 帖子高亮 取消高亮  
    结  帖 发  帖 回  复 
      

  7.   

    有项目管理经验的.NET开发的朋友,加上限500人的QQ群28720769,一起交流。