i have a table like:
create table police(
ssn
name
boss_name
salary
);
Insert into police values(1,’A’,’C’,10000);
Insert into police values(2,’B’,’D’,20000);
Insert into police values(3,’C’,’E’,30000);
Insert into police values(4,’D’,’E’,45000);
Insert into police values(5,’E’,NULL,55000);
I want a cursor that returns the total salary for the polices who have same boss. Here result will be:
30000(salary of C)+45000(salary of D)
as they both are under boss E. How I do it? How I find C and D as they are under E in ORACLE pl/sql or anonymous block?
Try this code:
Here you can find more information about cursors and loops.