zoukankan      html  css  js  c++  java
  • oracle语句中的常用一些小技巧

    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		

        

  • 相关阅读:
    servicestack and redis
    图片服务器
    CRQS介绍
    javascript闭包之购物车加减及提示
    javascript best practices
    EOF
    2012年回顾
    volatile
    通过inode来操作文件
    采样问题
  • 原文地址:https://www.cnblogs.com/xiao-zhang-blogs/p/7147442.html
Copyright © 2011-2022 走看看