热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

2016年11月7日周一:Kettle系统监测销售团队每日任务完成情况分析

本文介绍了2016年11月7日对Kettle系统中销售团队每日任务完成情况的分析。具体包括:目标表中的激活客户数是指当月前30天内未下过单的客户;通过SQL查询语句获取销售员的当月销售确认金额、订单总额、首单数量及激活客户数量等关键指标,以便全面评估销售业绩。

1、上面是目标表,其中激活客户数为当月每天之前30天未下单的客户

2、写SQL

SELECT a.销售员,c.当月销售确认额,a.当月订单额,b.当月首单数,b.当月激活数,
a1,b.b1,b.c1,a2,b.b2,b.c2,a3,b.b3,b.c3,a4,b.b4,b.c4,a5,b.b5,b.c5,a6,b.b6,b.c6,a7,b.b7,b.c7,a8,b.b8,b.c8,a9,b.b9,b.c9,a10,b.b10,b.c10,a11,b.b11,b.c11,a12,b.b12,b.c12,a13,b.b13,b.c13,a14,b.b14,b.c14,a15,b.b15,b.c15,
a16,b.b16,b.c16,a17,b.b17,b.c17,a18,b.b18,b.c18,a19,b.b19,b.c19,a20,b.b20,b.c20,a21,b.b21,b.c21,a22,b.b22,b.c22,a23,b.b23,b.c23,a24,b.b24,b.c24,a25,b.b25,b.c25,a26,b.b26,b.c26,a27,b.b27,b.c27,a28,b.b28,b.c28,
a29,b.b29,b.c29,a30,b.b30,b.c30,a31,b.b31,b.c31
FROM (SELECT a1.销售员,SUM(a1.金额) AS 当月订单额,#当月订单额及每天订单额SUM(IF(DAY(a1.订单日期)&#61;1,金额,NULL)) AS a1,SUM(IF(DAY(a1.订单日期)&#61;2,金额,NULL)) AS a2,SUM(IF(DAY(a1.订单日期)&#61;3,金额,NULL)) AS a3,SUM(IF(DAY(a1.订单日期)&#61;4,金额,NULL)) AS a4,SUM(IF(DAY(a1.订单日期)&#61;5,金额,NULL)) AS a5,SUM(IF(DAY(a1.订单日期)&#61;6,金额,NULL)) AS a6,SUM(IF(DAY(a1.订单日期)&#61;7,金额,NULL)) AS a7,SUM(IF(DAY(a1.订单日期)&#61;8,金额,NULL)) AS a8,SUM(IF(DAY(a1.订单日期)&#61;9,金额,NULL)) AS a9,SUM(IF(DAY(a1.订单日期)&#61;10,金额,NULL)) AS a10,SUM(IF(DAY(a1.订单日期)&#61;11,金额,NULL)) AS a11,SUM(IF(DAY(a1.订单日期)&#61;12,金额,NULL)) AS a12,SUM(IF(DAY(a1.订单日期)&#61;13,金额,NULL)) AS a13,SUM(IF(DAY(a1.订单日期)&#61;14,金额,NULL)) AS a14,SUM(IF(DAY(a1.订单日期)&#61;15,金额,NULL)) AS a15,SUM(IF(DAY(a1.订单日期)&#61;16,金额,NULL)) AS a16,SUM(IF(DAY(a1.订单日期)&#61;17,金额,NULL)) AS a17,SUM(IF(DAY(a1.订单日期)&#61;18,金额,NULL)) AS a18,SUM(IF(DAY(a1.订单日期)&#61;19,金额,NULL)) AS a19,SUM(IF(DAY(a1.订单日期)&#61;20,金额,NULL)) AS a20,SUM(IF(DAY(a1.订单日期)&#61;21,金额,NULL)) AS a21,SUM(IF(DAY(a1.订单日期)&#61;22,金额,NULL)) AS a22,SUM(IF(DAY(a1.订单日期)&#61;23,金额,NULL)) AS a23,SUM(IF(DAY(a1.订单日期)&#61;24,金额,NULL)) AS a24,SUM(IF(DAY(a1.订单日期)&#61;25,金额,NULL)) AS a25,SUM(IF(DAY(a1.订单日期)&#61;26,金额,NULL)) AS a26,SUM(IF(DAY(a1.订单日期)&#61;27,金额,NULL)) AS a27,SUM(IF(DAY(a1.订单日期)&#61;28,金额,NULL)) AS a28,SUM(IF(DAY(a1.订单日期)&#61;29,金额,NULL)) AS a29,SUM(IF(DAY(a1.订单日期)&#61;30,金额,NULL)) AS a30,SUM(IF(DAY(a1.订单日期)&#61;31,金额,NULL)) AS a31FROM &#96;a003_order&#96; AS a1WHERE a1.销售员 IS NOT NULL AND a1.城市&#61;"北京" AND DATE_FORMAT(a1.订单日期,"%Y%m")&#61;DATE_FORMAT(DATE_ADD(CURRENT_DATE,INTERVAL - 1 DAY),"%Y%m") AND a1.订单日期<CURRENT_DATE GROUP BY a1.销售员
)
AS a
LEFT JOIN (SELECT b5.销售员,SUM(IF(b5.激活情况&#61;"新增",1,NULL))AS 当月首单数,SUM(IF(b5.激活情况&#61;"重激活",1,NULL)) AS 当月激活数,#首单数SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;1,1,NULL)) AS b1,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;2,1,NULL)) AS b2,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;3,1,NULL)) AS b3,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;4,1,NULL)) AS b4,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;5,1,NULL)) AS b5,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;6,1,NULL)) AS b6,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;7,1,NULL)) AS b7,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;8,1,NULL)) AS b8,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;9,1,NULL)) AS b9,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;10,1,NULL)) AS b10,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;11,1,NULL)) AS b11,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;12,1,NULL)) AS b12,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;13,1,NULL)) AS b13,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;14,1,NULL)) AS b14,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;15,1,NULL)) AS b15,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;16,1,NULL)) AS b16,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;17,1,NULL)) AS b17,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;18,1,NULL)) AS b18,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;19,1,NULL)) AS b19,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;20,1,NULL)) AS b20,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;21,1,NULL)) AS b21,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;22,1,NULL)) AS b22,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;23,1,NULL)) AS b23,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;24,1,NULL)) AS b24,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;25,1,NULL)) AS b25,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;26,1,NULL)) AS b26,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;27,1,NULL)) AS b27,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;28,1,NULL)) AS b28,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;29,1,NULL)) AS b29,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;30,1,NULL)) AS b30,SUM(IF(b5.激活情况&#61;"新增" AND DAY(b5.当月首单日期)&#61;31,1,NULL)) AS b31,#SUM(IF(b5.激活情况&#61;"重激活",1,NULL)) AS 当月激活数,#激活数SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;1,1,NULL)) AS c1,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;2,1,NULL)) AS c2,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;3,1,NULL)) AS c3,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;4,1,NULL)) AS c4,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;5,1,NULL)) AS c5,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;6,1,NULL)) AS c6,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;7,1,NULL)) AS c7,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;8,1,NULL)) AS c8,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;9,1,NULL)) AS c9,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;10,1,NULL)) AS c10,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;11,1,NULL)) AS c11,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;12,1,NULL)) AS c12,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;13,1,NULL)) AS c13,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;14,1,NULL)) AS c14,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;15,1,NULL)) AS c15,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;16,1,NULL)) AS c16,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;17,1,NULL)) AS c17,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;18,1,NULL)) AS c18,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;19,1,NULL)) AS c19,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;20,1,NULL)) AS c20,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;21,1,NULL)) AS c21,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;22,1,NULL)) AS c22,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;23,1,NULL)) AS c23,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;24,1,NULL)) AS c24,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;25,1,NULL)) AS c25,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;26,1,NULL)) AS c26,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;27,1,NULL)) AS c27,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;28,1,NULL)) AS c28,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;29,1,NULL)) AS c29,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;30,1,NULL)) AS c30,SUM(IF(b5.激活情况&#61;"重激活" AND DAY(b5.当月首单日期)&#61;31,1,NULL)) AS c31 FROM (SELECT b3.用户ID,b3.销售员,b3.订单日期 AS 当月首单日期,SUM(IF(DATE(b4.订单日期)<b3.订单日期 AND b4.金额>0,b4.金额,NULL)) AS 当月首单日以前总金额,SUM(IF(DATE(b4.订单日期)<&#61;DATE_ADD(b3.订单日期,INTERVAL -30 DAY) AND b4.金额>0,b4.金额,NULL)) AS 当月首单日前30天之前金额,SUM(IF(DATE(b4.订单日期)>DATE_ADD(b3.订单日期,INTERVAL -30 DAY) AND DATE(b4.订单日期)<b3.订单日期 AND b4.金额>0,b4.金额,NULL)) AS 当月首单日前30天金额,b3.订单额 AS 当月首单日金额,CASE WHEN SUM(IF(DATE(b4.订单日期)<b3.订单日期 AND b4.金额>0,b4.金额,NULL)) IS NULL THEN "新增"WHEN SUM(IF(DATE(b4.订单日期)>DATE_ADD(b3.订单日期,INTERVAL -30 DAY) AND DATE(b4.订单日期)<b3.订单日期 AND b4.金额>0,金额,NULL)) IS NOT NULL THEN "留存"WHEN SUM(IF(DATE(b4.订单日期)<&#61;DATE_ADD(b3.订单日期,INTERVAL -30 DAY) AND b4.金额>0,金额,NULL)) IS NOT NULL AND SUM(IF(DATE(b4.订单日期)>DATE_ADD(b3.订单日期,INTERVAL -30 DAY) AND DATE(b4.订单日期)<b3.订单日期 AND b4.金额>0,金额 ,NULL)) IS NULL THEN "重激活"ELSE NULL END AS 激活情况FROM (SELECT b2.用户ID,b2.订单日期,b2.销售员 AS 销售员,b2.订单额#取出当月首单订单日期 首单销售 首单额 以这个日期往前推30天判断激活留存情况 FROM ( SELECT b1.用户ID,DATE(b1.订单日期) AS 订单日期,b1.销售员,SUM(金额) AS 订单额 #当月下单用户每天明细FROM &#96;a003_order&#96; AS b1WHERE b1.城市&#61;"北京" AND DATE_FORMAT(b1.订单日期,"%Y%m")&#61;DATE_FORMAT(DATE_ADD(CURRENT_DATE,INTERVAL - 1 DAY),"%Y%m") AND b1.订单日期<CURRENT_DATE AND b1.金额>0GROUP BY b1.用户ID,DATE(b1.订单日期)) AS b2GROUP BY b2.用户ID) AS b3LEFT JOIN &#96;a003_order&#96; AS b4 ON b4.用户ID&#61;b3.用户ID#where b3.用户ID&#61;22200GROUP BY b3.用户ID) AS b5WHERE b5.销售员 IS NOT NULLGROUP BY b5.销售员
)
AS b ON a.销售员&#61;b.销售员
LEFT JOIN (#05表销售确认额SELECT c1.销售员,SUM(c1.销售额) AS 当月销售确认额FROM &#96;a005_account&#96; AS c1WHERE c1.销售员 IS NOT NULL AND c1.城市&#61;"北京" AND DATE_FORMAT(c1.应收日,"%Y%m")&#61;DATE_FORMAT(DATE_ADD(CURRENT_DATE,INTERVAL - 1 DAY),"%Y%m") AND c1.应收日<CURRENT_DATEGROUP BY c1.销售员
)
AS c ON a.销售员&#61;c.销售员
ORDER BY a.当月订单额 DESC

3、做excel模板

将上面SQL数据导入excel中 设置好格式表头 删除数据  还是用到SUMif函数 把所有销售员当月每天的这两个指标都用公式计算出来

4、保存excel模板 文件名设置成英文名  * _style.xlsx 这样结尾最好

5、设置kettle转换 

设置好数据库连接服务器 表输入里选择数据库连接 表输出选择excel表输出 调用第4步excel模板文件* _style.xlsx 

6、执行转换检测生成的数据和预设的格式是否相同 如果相同进行第7步即可 不相同再调整excel模板

7、设置发邮件作业 收件人地址 发件人地址 用户名 密码 服务器端口等设置好

转:https://www.cnblogs.com/Mr-Cxy/p/6038933.html



推荐阅读
  • 本文深入探讨了SQL数据库中常见的面试问题,包括如何获取自增字段的当前值、防止SQL注入的方法、游标的作用与使用、索引的形式及其优缺点,以及事务和存储过程的概念。通过详细的解答和示例,帮助读者更好地理解和应对这些技术问题。 ... [详细]
  • 1.执行sqlsever存储过程,消息:SQLServer阻止了对组件“AdHocDistributedQueries”的STATEMENT“OpenRowsetOpenDatas ... [详细]
  • 本文详细介绍了优化DB2数据库性能的多种方法,涵盖统计信息更新、缓冲池调整、日志缓冲区配置、应用程序堆大小设置、排序堆参数调整、代理程序管理、锁机制优化、活动应用程序限制、页清除程序配置、I/O服务器数量设定以及编入组提交数调整等方面。通过这些技术手段,可以显著提升数据库的运行效率和响应速度。 ... [详细]
  • 优化SQL Server批量数据插入存储过程的实现
    本文介绍了一种改进的SQL Server存储过程,用于生成批量插入语句。该方法不仅提高了性能,还支持单行和多行模式,适用于SQL Server 2005及以上版本。 ... [详细]
  • 主调|大侠_重温C++ ... [详细]
  • 本文介绍了一个基于 Java SpringMVC 和 SSM 框架的综合系统,涵盖了操作日志记录、文件管理、头像编辑、权限控制、以及多种技术集成如 Shiro、Redis 等,旨在提供一个高效且功能丰富的开发平台。 ... [详细]
  • 本文深入探讨了MySQL中常见的面试问题,包括事务隔离级别、存储引擎选择、索引结构及优化等关键知识点。通过详细解析,帮助读者在面对BAT等大厂面试时更加从容。 ... [详细]
  • docker镜像重启_docker怎么启动镜像dock ... [详细]
  • 本文介绍了如何通过在数据库表中增加一个字段来记录文章的访问次数,并提供了一个示例方法用于更新该字段值。 ... [详细]
  • 本文档汇总了Python编程的基础与高级面试题目,涵盖语言特性、数据结构、算法以及Web开发等多个方面,旨在帮助开发者全面掌握Python核心知识。 ... [详细]
  • 如何从python读取sql[mysql基础教程]
    从python读取sql的方法:1、利用python内置的open函数读入sql文件;2、利用第三方库pymysql中的connect函数连接mysql服务器;3、利用第三方库pa ... [详细]
  • 福克斯新闻数据库配置失误导致1300万条敏感记录泄露
    由于数据库配置错误,福克斯新闻暴露了一个58GB的未受保护数据库,其中包含约1300万条网络内容管理记录。任何互联网用户都可以访问这些数据,引发了严重的安全风险。 ... [详细]
  • 探讨 HDU 1536 题目,即 S-Nim 游戏的博弈策略。通过 SG 函数分析游戏胜负的关键,并介绍如何编程实现解决方案。 ... [详细]
  • 本文详细介绍了一种通过MySQL弱口令漏洞在Windows操作系统上获取SYSTEM权限的方法。该方法涉及使用自定义UDF DLL文件来执行任意命令,从而实现对远程服务器的完全控制。 ... [详细]
  • 智能医疗,即通过先进的物联网技术和信息平台,实现患者、医护人员和医疗机构之间的高效互动。它不仅提升了医疗服务的便捷性和质量,还推动了整个医疗行业的现代化进程。 ... [详细]
author-avatar
我是小章丘
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有