I have the following data:

I would like to express the FTSEAllShare in terms of all its primitives (ie. Corp1, Corp2, Corp3, Corp4).
I’ve written a WHILE loop that repeatedly SELF JOINs MemberName to GroupName and COALESCEs the resulting MemberName, but I’ve been reading about recursive CTEs and thought that they may offer a simpler way of doing it.
I’m not good with recursive code and I find myself getting confused everytime I try.
Could someone please help me out with this and suggest how I may use a recursive CTE to express the FTSEAllShare in terms of its 4 primitives?
Kind regards
Like this:
Live Demo
This will give you all the members that belongs to the group
FRSEAllShare, or any of its grandchilds groups, with a new columnlevelto select them by level.