sum函数求和

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_35403739/article/details/53138521
def sum(numbers : Int*) ={ var result =0; for(element <- numbers) result += element; result}
调用这个函数
sum(1,2,3,4,5,6)最终会让集合里的数相加      








下面延伸一个比较重要的概念
上面因为我们传入的是1到5的和,那么我们要计算1到100的和呢?
我们可以使用这个语法:
sum(1 to 100: _*)   : _*相当于把里面的元素提取出来
就可以计算啦
展开阅读全文

求和计算Sum函数的使用

05-13

【课程内容】<br />n所涉及的具体内容包括输入录入技巧、排序、筛选、函数公式、数据透视表、图表、汇总等功能应用,并结合大量的企业应用实例,以互动的方式将解决思路和操作过程逐一呈现。<br /><br />n【课程特点】<br />n1、190节大容量课程:包含了Excel软件的大部分知识点;<br />n2、创新的教学模式:手把手教您电子表格,一看就懂,一学就会;<br />n3、完美贴心的操作提示:让您的眼睛始终处于操作的焦点位置,不用再满屏找光标;<br />n4、语言简洁精练:瞄准问题的核心所在,减少对思维的干扰,并节省您宝贵的时间;<br />n5、视频短小精悍:即方便于您的学习和记忆,也方便日后对功能的检索;<br /><br /><br />n【互动教程的特点】<br />n•互动性<br />n-首创互动式学习,不同于以往的任何一种学习方式,不看视频不看书,轻松,高效,好玩<br />n-手把手教学,一步步引导操作,实时看到效果,就像自己在操作一样,信心满满<br />n-即点即学,课程内可根据自己的需要,随时调整界面上方进度条,重复操作,加强记忆<br />n-强大的学习跟踪系统,对整体学习进度一目了然,及时调整学习计划,查疑补漏<br /><br />n•人性化<br />n-界面设计简洁,操作简单,没有繁琐的按钮,一点就可直接进入学习状态<br />n-贴心小提示,读懂你的小心思,零基础快速入门,学习无压力,不尴尬<br />n-超多原理解析,疑问解答,如同专业Excel导师亲身指导,不翻书快速记忆,Excel小白迅速成长<br /><br />n•实用性<br />n-课程由浅入深,操作过程详细剖析,一步步模仿,马上就会做。<br />n-涉及排序、筛选、函数公式、数据透视表、图表、汇总等核心功能的课程编排,通俗易懂不头疼<br />n-互动+观看视频,两种学习方式切换,上班路上,地铁里享受随时随地自由学习<br /><br />n通过本课程的学习,您将逐步掌握Excel 2016的各项功能和使用技巧。从而提高您的办公效率,早做完,不加班!!!<br /><br />

sum求和去重问题

10-22

[code=sql]SELECT B.TREE_NODE rn , SUM(CASE WHEN A.EMPL_CLASS IN ('001' rn , '009' rn , '002' rn , '003' rn , '004' rn , '005' rn , '006' rn , '007' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('001' rn ,'009') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('009') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('008' rn , '010' rn , '011' rn , '016' rn , '017') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('008') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('011') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('017') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('002' rn , '003' rn , '004' rn , '005' rn , '006' rn , '007') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('002') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('004') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('003') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('006') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN A.EMPL_CLASS IN ('005' rn ,'007') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('01' rn , '02' ) rn AND D.SPG_COMP2_LEVEL = '01' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('03' rn ,'04' rn , '05') rn AND D.SPG_COMP2_LEVEL = '01' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('01' rn , '02' ) rn AND D.SPG_COMP2_LEVEL = '02' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('03' rn ,'04' rn , '05') rn AND D.SPG_COMP2_LEVEL = '02' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('01' rn , '02' ) rn AND D.SPG_COMP2_LEVEL = '03' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('03' rn ,'04' rn , '05') rn AND D.SPG_COMP2_LEVEL = '03' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('01' rn , '02' ) rn AND D.SPG_COMP2_LEVEL = '04' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID IN ('03' rn ,'04' rn , '05') rn AND D.SPG_COMP2_LEVEL = '04' rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn , SUM(CASE WHEN E.SPG_POS_LEV_ID NOT IN ('01' rn , '02' rn , '03' rn , '04' rn , '05') rn AND a.EMPL_CLASS IN ('001' rn , '009' rn , '008' rn , '010' rn , '011' rn , '016' rn , '017' rn , '018' rn , '019' rn , '020') THEN 1 ELSE 0 END) rn FROM PS_JOB A rn , PS_SPH_FOR_DEPT_TL B rn , PS_DEPT_TBL C rn , PS_COMPANY_TBL D rn , PS_JOBCODE_TBL E rn WHERE A.EFFDT = ( rn SELECT MAX(A1.EFFDT) rn FROM PS_JOB A1 rn WHERE A1.EMPLID = A.EMPLID rn AND A1.EMPL_RCD = A.EMPL_RCD rn AND A1.EFFDT <= :1) rn AND A.EFFSEQ = ( rn SELECT MAX(A2.EFFSEQ) rn FROM PS_JOB A2 rn WHERE A2.EMPLID = A.EMPLID rn AND A2.EMPL_RCD = A.EMPL_RCD rn AND A2.EFFDT = A.EFFDT) rn AND A.DEPTID = B.TREE_NODE_CHILD rn AND (B.SPG_DEPT_CLASS = '01' rn OR B.SPG_DEPT_CLASS = '18') rn AND A.JOB_INDICATOR = 'P' rn AND A.HR_STATUS = 'A' rn AND A.BUSINESS_UNIT = 'BU100' rn AND B.SETID = C.SETID rn AND B.TREE_NODE = C.DEPTID rn AND C.EFFDT = ( rn SELECT MAX(C1.EFFDT) rn FROM PS_DEPT_TBL C1 rn WHERE C1.SETID = C.SETID rn AND C1.DEPTID = C.DEPTID rn AND C1.EFFDT <= :1) rn AND D.EFFDT = ( rn SELECT MAX(D1.EFFDT) rn FROM PS_COMPANY_TBL D1 rn WHERE D1.COMPANY = D.COMPANY rn AND D1.EFFDT <= :1) rn AND E.EFFDT = ( rn SELECT MAX(E1.EFFDT) rn FROM Ps_Jobcode_Tbl E1 rn WHERE E1.setid = E.setid rn AND E1.jobcode = E.jobcode rn AND E1.EFFDT <= :1) rn AND A.COMPANY = D.COMPANY rn AND A.JOBCODE = E.JOBCODE rn AND EXISTS ( rn SELECT 1 rn FROM PS_SPH_DEPT_TREE M rn WHERE M.SPH_PARENT_NODE = :3 rn AND B.TREE_NODE = DECODE(:2, 'Y', M.SPH_CHILD_NODE, :3) rn AND (M.SPH_CHILDNOD_CLASS = '01' rn OR M.SPH_CHILDNOD_CLASS = '18')) rn GROUP BY B.TREE_NODE, C.SPG_SORT_COMTREE rn ORDER BY C.SPG_SORT_COMTREE[/code] 论坛

没有更多推荐了,返回首页