Select Top - LVL SUM SAL From Select Connect - by - Root MNGR As Top - LVL SAL From Emp Connect by Prior Emp MNGR Group by Top - LVL

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Q) I have table with columns (Employee, Manager, Salary).

Need to calculate
aggregate salary for all employees corresponding to top-level managers in one
SQL.
ANS) SELECT TOP_LVL, SUM(SAL) FROM (SELECT CONNECT_BY_ROOT MNGR AS TOP_LVL, SAL
FROM EMP CONNECT BY PRIOR EMP = MNGR) GROUP BY TOP_LVL

select
seq#, event, p1, p2, p3
from
v$session_wait_history
where
sid = <yoursid>
order by seq;

You might also like