我有一张像这样的桌子:
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);
我想要一个cursor
返回total salary
的polices who have same boss
。这里的结果将是:
30000(salary of C)+45000(salary of D)
因为他们都在老板 E 之下。我是怎么做到的?我如何在 ORACLE pl/sql 或匿名块的 E 下找到 C 和 D?