2007年4月2日

DB2 当中Rollup得用法,得一些看法。

摘要: selectDEPARTMENT,Name,sum(amount)assum,count(*)ascountfromsaleinnerjoinEmployeeonliaohaibing.EMPLOYEE.ID=liaohaibing.SALE.EMPLOYEEIDinnerjoinliaohaibing.DEPARTMENTonliaohaibing.DEPARTMENT.DEPARTMENTID=liaohaibing.EMPLOYEE.DEPARTMENTIDwhereliaohaibing.DEPARTMENT.DEPARTMENTIDin(2,4,5,9)groupbyrollup(D 阅读全文

posted @ 2007-04-02 11:28 小土泥 阅读(1421) 评论(0) 推荐(0) 编辑

Reporting Function

摘要: SELECT ID,DepartmentID,Pay,SUM(PAY) Over(Partition BY DepartmentID)as Total,Pay*100/SUM(Pay) Over(Partition by DepartmentID) as "Pct of c2"FROM TempTableWHERE DepartmentID IN(15,20);SUM(PAY) Over(Partition BY DepartmentID)as Total这句话是求出这个用户所有部门得工资总合。Pay*100/SUM(Pay) Over(Partition by Depar 阅读全文

posted @ 2007-04-02 00:01 小土泥 阅读(206) 评论(0) 推荐(0) 编辑

导航