SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table T ( idGeo INT IDENTITY(1,1), GEO VARCHAR(64), PARENTID INT ); insert into T (GEO, PARENTID) values ( 'EMEA', NULL), ( 'France', 1), ( 'mIDCAPSfRANCE', 2), ( 'Germany', 1), ( 'France exl midcaps', 2), ( 'Amercias', NULL), ( 'US', 6); select T.idGeo, T.GEO, T1.GEO [GEO Level 1], T2.GEO [GEO Level 2] from T left join T T1 on T.PARENTID = T1.idGeo left join T T2 on T1.PARENTID = T2.idGeo;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear