sum with column calculation : SUM « Aggregate 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 » Aggregate Functions » SUM 
sum with column calculation
   


create table emp(
         no                 integer         primary key
        ,name               varchar2(20)    not null
        ,salary             number(10)
        ,city               varchar2(20)
);

insert into emp(no, name, salary, city)
        values (1,'Nancy','2212','Paris');

insert into emp(no, name, salary, city)
        values (2,'Tom','3212','Barton');

insert into emp(no, name, salary, city)
        values (3,'Jason','4212','Island');

insert into emp(no, name, salary, city)
        values (4,'Jack','5212','Paris');

        

select sum(salary"TOTAL Salary",
           sum(salary * 12"GROSS $"
      from emp
      group by city;


TOTAL Salary    GROSS $
------------ ----------
        4212      50544
        3212      38544
        7424      89088
        

drop table emp;
   
    
  
Related examples in the same category
1.SUM: total for all NOT NULL values, accepts only numeric datatype values
2.Syntax: SUM([DISTINCT]|[ALL] )
3.GROUP BY function would produce inventory totals distributed across different vendors
4.SUM function and NULLs
5.Using the SUM function with GROUP BY Clause
6.Add an "OTHER" and "TOTAL" column to the report:
7.Compute sum on salary
8.Sum column for a certain time period
9.Sum salary group by department number
10.Sum salary over
11.Sum() function and having clause
12.Doing calculation in sum() function
13.Wrap case when into sum() function
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.