随笔分类 -  DB2 学习

DB2 学习笔记宿主变量、游标、 Drop、Create、Alter、锁、性能维护。
摘要:宿主变量。exec sqlupdate t1set c1=:newvaluewhere c1 = :oldvalue;Exec sqlselect lastname,firstnameinto :last,:fistfrom t1where empon=:id;游标得定义________________Exec sqlDeclare c1 cursor forselect c1,c2 from t1;Exec sql open c1;Exec sql fetch c1 into :id,:name...Exec sql close c1;//光标得关闭,或游标得关闭处理异常情况SQLSTATE 阅读全文

posted @ 2007-04-04 21:54 小土泥 阅读(810) 评论(0) 推荐(0) 编辑

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 小土泥 阅读(1425) 评论(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) 编辑

Sale表中横列值转换成竖列显示。
摘要:SELECTEmployeeID,max(caseSaleDatewhen'2007-01-01'thenamountelsenullend)asjan,max(caseSaleDatewhen'2007-02-01'thenamountelsenullend)asfeb,max(caseSaleDatewhen'2007-03-01'thenamountelsenullend)asmar,max(caseSaleDatewhen'2007-04-01'thenamountelsenullend)asapr,max(caseSal 阅读全文

posted @ 2007-03-27 23:13 小土泥 阅读(350) 评论(0) 推荐(0) 编辑

刚学习Db2 对一条 select 语句得疑问.
摘要:insertintoliaohaibing.Employee(ID,Name,Password,Department)selectID,Name,Password,DepartmentfromNULLID.Employee;不知道为什么这条句语还能执行成功. 阅读全文

posted @ 2007-03-27 17:33 小土泥 阅读(136) 评论(0) 推荐(0) 编辑

导航