📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

Which SQL feature is used to query all levels of a self-referencing hierarchy, such as all subordinates under a manager?

A. A CHECK constraint
B. A simple SELECT with no join
C. A recursive common table expression (CTE) ✅
D. A UNION of unrelated tables

Correct Answer: C. A recursive common table expression (CTE)

Explanation

A recursive CTE can walk the hierarchy level by level, which a single ordinary join cannot do for an unknown depth.