oracle olap函数
/*sum()over()*/
--默认计算所有行的合计
select t.empno,t.ename,t.sal,t.deptno,sum(t.sal)over()
from scott.emp t;
--partition by分组合计
select t.empno,t.ename,t.sal,t.deptno,
sum(t.sal)over(partition by t.deptno)
from scott.emp t
order by t.deptno,t.sal;
--partition by order by deptno分组累计
select t.empno,t.ename,t.sal,t.deptno,
sum(t.sal)over(partition by t.deptno order by t.sal)
from scott.emp t;
--rows n preceding 取当前行+前n行=(n+1)行
--通过order by desc可以取后n行
select t.empno,t.ename,t.sal,t.deptno,
sum(t.sal)over(order by t.deptno,t.sal rows 1 preceding)
from scott.emp t;
--rows 2n+1 取当前行+前n行+后n行=(2n+1)行
select t.empno,t.ename,t.sal,t.deptno,
sum(t.sal)over(order by t.deptno,t.sal rows between 1 preceding and 1 following)
from scott.emp t;
/*first_value() over()*/
select deptno,ename,sal,hiredate,
first_value(ename) over(partition by deptno order by sal asc rows 5 preceding) first_ename
from emp order by hiredate asc;
/*avg()over count() over() max()over() min()over()*/
select deptno,sal,
sum(sal)over(partition by deptno) as sumsal,
avg(sal)over(partition by deptno) as avgsal,
count(*)over(partition by deptno) as count,
max(sal)over(partition by deptno) as maxsal
from emp;
/*rank()over() dese_rank()over() row_number()over()*/
select empno, deptno, sal,
rank() over (order by deptno desc nulls last) as rank,
dense_rank() over (partition by deptno order by sal desc nulls last) as dense_rank,
row_number() over(partition by deptno order by sal desc nulls last) as row_number
from emp;
/*stddev() over()*标准差/
select empno, deptno, sal,stddev(sal) over(order by sal)
from emp;
相关文档:
第一种情况:无返回值.
create or replace procedure test_a(param1 in varchar2,param2 in varchar2) as
begin
insert into test value(param1,param2);
&nb ......
来源(http://www.javaeye.com/topic/190221)
一、 常用日期数据格式
1.Y或YY或YYY 年的最后一位,两位或三位
SQL> Select to_char(sysdate,'Y') from dual;
TO_CHAR(SYSDATE,'Y')
--------------------
7
SQL> Select to_char(sysdate,'YY') from dual;
TO_CHAR(SYSDATE,'YY')
---------------------
07 ......
一。job的运行频率设置
1.每天固定时间运行,比如早上8:10分钟:Trunc(Sysdate+1) + (8*60+10)/24*60
2.Toad中提供的:
每天:trunc(sysdate+1)
每周:trunc(sysdate+7)
每月:trunc(sysdate+30)
每个星期日:next_day(trunc(sysdate),'SUNDAY')
每天6点:trunc(sysdate+1)+6/24
半个小时:sysdate+30/1440
3.每个 ......
对初学ORACLE的人一时很难分清ORACLE中关于“空间”的概念,比如表空间 临时表空间 用户表空间等,对于由SQL转到ORACLE的就更加混淆了,让人感觉ORACLE繁琐;繁琐在哪儿,我整理罗列如下:
1.ORACLE自带工具不十分易用;
2.ORACLE第三方工具易上手,但难深入;
&n ......
ORACLE中数据字典视图分为3大类, 用前缀区别,分别为:USER,ALL 和 DBA,许多数据字典视图包含相似的信息。
USER_*:有关用户所拥有的对象信息,即用户自己创建的对象信息
ALL_*:有关用户可以访问的对象的信息,即用户自己创建的对象的信息加上其他用户创建的对象但该用户有权访问的信息
DBA_* ......