66. Region Hierarchy

This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.

Given a hierarchical table, which displays various cities and regions in the State of Israel. For example – the Northern region (serial number 423) is located in the State of Israel (serial number 938), the city of Haifa (serial number 261) is located in the Northern region (serial number 423), and so on.

CREATE TABLE IsraelRegions
(regionID int,
regionName varchar(25),
InRegion int)

To read more

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…