1.时间的处理
获取年: to_char(hiredate,'MM');---这里hiredate是date类型,格式1981/4/2
同理:to_char(hiredate,'yyyy') year,to_char(hiredate,'MM') month
2.表中存在树形结构
start with 条件1 connect by prior 条件2;---条件2是表中的父子字段。
例如:oracle自带scott.emp表,这里存在树形关系。
查询'JONES'员工及所有其直接、间接下属员工的信息:
select e.* from emp e start with ename='JONES' connect by prior empno=mgr;
结果:
1 7566 JONES MANAGER 7839 1981/4/2 2975.00 20 2 7788 SCOTT ANALYST 7566 1987/4/19 3000.00 20 3 7876 ADAMS CLERK 7788 1987/5/23 1100.00 20 4 7902 FORD ANALYST 7566 1981/12/3 3000.00 20 5 7369 SMITH CLERK 7902 1980/12/17 800.00