sum with column calculation : SUM « Aggregate Functions « Oracle PL / SQL






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