N/APosted on - 12/05/2011
DB2 can return SUM function apart within a declaration. If I have the following situation: POWER SELECT SUM (AMOUNT), COUNT (*) FROM table WHERE POWER IN (180002.180092) gives Rama the amount and the Count 180,002, +100.3 which I can return into two values, one is the positive values of the number and one for negative numbers yield: Branch, credit, debit, account 180002, -100, +200.3. How can I accomplish this? Any ideas? Thanks.
Return Sum Function in DB2
You will need to use the SUM function so as to able to calculate the accumulated total of all values in the specified column or expression. As an example to guide you, which you can of course edit and customize to suit your situation, you will need to something close to the following: (The following SQL statement are meant to calculate the total yearly monetary output for a corporation)
What the SQL statement does is that it adds each of the employee's salary, commission, and bonus, and after that it will aggregate the results into a single value that will represent the total amount of compensation that will be paid to all employees.