DB2 - finding SUM of salaries of employees with out using SUM function

Bandi
Posted by Bandi under Others category on | Points: 40 | Views : 329
In DB2, we can create ananymous blocks to write PL SQL code..

The following is the code snippet to sum up the salaries with out using SUM inbuilt function...

BEGIN
DECLARE V_SUM DECIMAL (10, 2) DEFAULT 0.0;
FOR I AS SELECT SALARY FROM EMPLOYEES
DO
SET V_SUM = V_SUM + I.SALARY;
END FOR;
END@

Comments or Responses

Login to post response