partition clause : PARTITION « Analytical Functions « Oracle PL / SQL

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » Analytical Functions » PARTITION 




partition clause
  
create table employee(
         no                 integer         primary key
        ,lastname               varchar2(20)    not null
        ,salary                 number(3)
        ,dept_no                 integer
);


insert into employee(no, lastname, salary,dept_no)
             values (1,'Tom', 400,1);

insert into employee(no, lastname, salary,dept_no)
             values (2,'Jack', 300,2);

insert into employee(no, lastname, salary,dept_no)
             values (3,'Lee', 200,3);

insert into employee(no, lastname, salary,dept_no)
             values (4,'Smith', 100,4);


select lastname , dept_no, salary,
       sum(salaryover (partition by dept_nototal_salary
from employee
order by dept_no, lastname;


LASTNAME                DEPT_NO     SALARY TOTAL_SALARY
-------------------- ---------- ---------- ------------
Tom                           1        400          400
Jack                          2        300          300
Lee                           3        200          200
Smith                         4        100          100


drop table employee;


   
  














Related examples in the same category
1.Partitioning with PARTITION_BY
2.Use partitioning in the OVER clause of the aggregate-analytical function like this
3.PARTITION BY: divide the groups into subgroups
4.Count(*) over partition
5.Dense_rank over partition by
6.rank and dense_rank over partition
7.count(*) over partition by, order by and range unbounded preceding
8.dense_rank() over partition by, order by
9.Top with partition
10.Partition Window
11.PARTITION BY (JOB title) and right outer join
12.SPREADSHEET PARTITION BY
13.sum salary over PARTITION BY
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.