-2

How to calculate sum of calcoulated column in detail table in jdeveloper Ex. In employee view add column as "calculate column type" his name is "avragesal" it calculate salary*20%

How can calculate sum "avragesal"for each department

For more explain In employee view

Dep_id.    Name.       Salary.    avragesal 
100        Jone.       1000.      200
100        XXX.        3000.      600
100        Zzz.        2000.      400
200        Ttt.        500.       100
200        Hhh.        700.       140
200        Ooo.        1200.      240

Iwana in department view

Dep_id.         Sumavragesal
100                     1200
200                      480

2 Answers2

0

Kind of hard to understand what you are asking, but I think you want the sum of the average salary per department:

select dep_id, sum(avragesal)
from employee 
group by dep_id

The Oracle Docs is your friend.

OldProgrammer
  • 10,029
  • 3
  • 24
  • 39
  • avragesal not real column it calcoulated colmn in viewobject and i wanna to sum this for each record in master table – user11629925 Jun 25 '19 at 22:26
0

It appears that your EMPLOYEE view is defined similarly to

CREATE OR REPLACE VIEW EMPLOYEE AS
  SELECT DEP_ID,
         NAME,
         SALARY
    FROM EMPLOYEE_TBL;

If this is the case (or something similar to this) then to add your AVRAGESAL column you'd do something like

CREATE OR REPLACE VIEW EMPLOYEE AS
  SELECT DEP_ID,
         NAME,
         SALARY,
         SALARY * 0.20 AS AVRAGESAL
    FROM EMPLOYEE_TBL;

Then to sum up EMPLOYEE.AVRAGESAL by department in the DEPARTMENT view you'd use something similar to

CREATE OR REPLACE VIEW DEPARTMENT AS
  SELECT DEP_ID,
         SUM(AVRAGESAL) AS AVRAGESAL
    FROM EMPLOYEE
    GROUP BY DEP_ID
    ORDER BY DEP_ID

You may need to modify this because I don't know what your EMPLOYEE view looks like, but hopefully this gives you an idea of how to proceed.

halfer
  • 18,701
  • 13
  • 79
  • 158