/*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;
¶Ô³õѧORACLEµÄÈËһʱºÜÄÑ·ÖÇåORACLEÖйØÓÚ“¿Õ¼ä”µÄ¸ÅÄ±ÈÈç±í¿Õ¼ä ÁÙʱ±í¿Õ¼ä Óû§±í¿Õ¼äµÈ£¬¶ÔÓÚÓÉSQLתµ½ORACLEµÄ¾Í¸ü¼Ó»ìÏýÁË£¬ÈÃÈ˸оõORACLE·±Ëö£»·±ËöÔÚÄĶù£¬ÎÒÕûÀíÂÞÁÐÈçÏ£º
1.ORACLE×Ô´ø¹¤¾ß²»Ê®·ÖÒ×Óã»
2.ORACLEµÚÈý·½¹¤¾ßÒ×ÉÏÊÖ£¬µ«ÄÑÉîÈ룻
&n ......
Éí¾ÓOracle ¹Ø¼üÓ¦ÓõĿª·¢ºÍά»¤ÍŶӣ¬ÄúÒ»¶¨ÉîÖªÑз¢¹ÜÀíµÄÖØÒª¡£ÈçºÎÀûÓÃרҵ»¯Oracle ÍŶӿª·¢½â¾ö·½°¸£¬ÊµÏÖ¸ßЧµÄÍŶӿª·¢¡¢×î¼ÑÓ¦ÓÃÐÔÄܺÍÀíÏëµÄ½»¸¶ÖÊÁ¿£¬ÊÇQuest Software±¾´ÎÓëÄú̽ÌֵĺËÐÄ»°Ìâ¡£
´ÓÊý¾Ý¿âµÄÉè¼Æ¡¢½¨Ä£¡¢±àÂ룬µ½Ó ......
ORACLEÖÐÊý¾Ý×ÖµäÊÓͼ·ÖΪ3´óÀà, ÓÃǰ׺Çø±ð£¬·Ö±ðΪ£ºUSER£¬ALL ºÍ DBA£¬Ðí¶àÊý¾Ý×ÖµäÊÓͼ°üº¬ÏàËƵÄÐÅÏ¢¡£
USER_*:ÓйØÓû§ËùÓµÓеĶÔÏóÐÅÏ¢£¬¼´Óû§×Ô¼º´´½¨µÄ¶ÔÏóÐÅÏ¢
ALL_*£ºÓйØÓû§¿ÉÒÔ·ÃÎʵĶÔÏóµÄÐÅÏ¢£¬¼´Óû§×Ô¼º´´½¨µÄ¶ÔÏóµÄÐÅÏ¢¼ÓÉÏÆäËûÓû§´´½¨µÄ¶ÔÏ󵫸ÃÓû§ÓÐȨ·ÃÎʵÄÐÅÏ¢
DBA_* ......