29.分析函数

1.求和

scott@ORCLPDB01 2023-02-26 20:44:09> select ename,sal,(select sum(sal) from emp) tsal from emp;

ENAME		  SAL	    TSAL
---------- ---------- ----------
SMITH		  800	   29025
ALLEN		 1600	   29025
WARD		 1250	   29025
JONES		 2975	   29025
MARTIN		 1250	   29025
BLAKE		 2850	   29025
CLARK		 2450	   29025
SCOTT		 3000	   29025
KING		 5000	   29025
TURNER		 1500	   29025
ADAMS		 1100	   29025
JAMES		  950	   29025
FORD		 3000	   29025
MILLER		 1300	   29025

14 rows selected.

Elapsed: 00:00:00.00

scott@ORCLPDB01 2023-02-26 20:44:34> select sal,sum(sal) over() tsal from emp;

       SAL	 TSAL
---------- ----------
       800	29025
      1600	29025
      1250	29025
      2975	29025
      1250	29025
      2850	29025
      2450	29025
      3000	29025
      5000	29025
      1500	29025
      1100	29025
       950	29025
      3000	29025
      1300	29025

14 rows selected.

Elapsed: 00:00:00.00

 

posted @ 2023-02-26 20:48  竹蜻蜓vYv  阅读(14)  评论(0编辑  收藏  举报