欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle sqlover用法

程序员文章站 2022-07-04 13:57:28
--求和两种结果相同 select e.employee_id ,e.first_name,e.salary,sum(e.salary) from employees e group by e.em...

--求和两种结果相同

select e.employee_id ,e.first_name,e.salary,sum(e.salary)

from employees e

group by e.employee_id ,e.first_name,e.salary;

select e.employee_id ,e.first_name,e.salary,sum(e.salary) over() sum

from employees e;

--求和

--第二行的sum=第一行里的sal+第二行里的sal;

-- 第二行的sum=第一行里的sal+第二行里的sal+第三行里的sal;

select e.employee_id,

e.department_id,

e.first_name,

e.salary,

sum(e.salary) over(order by e.first_name) sum

from employees e;

--每个sum的值都是把last_name相同的sal值进行求和。

select e.employee_id,

e.department_id,

e.last_name,

e.salary,

sum(e.salary) over(partition by e.last_name) sum

from employees e;