题目
有如下一张表G1211
希望得到如下结果
测试数据
CREATE TABLE G1211(
ID INT,
[NAME] VARCHAR(10),
ParentId INT
)
INSERT INTO G1211 VALUES (1,'北京市',0);
INSERT INTO G1211 VALUES (2,'广东省',0);
INSERT INTO G1211 VALUES (3,'昌平区',1);
INSERT INTO G1211 VALUES (4,'海淀区',1);
INSERT INTO G1211 VALUES (5,'广州市',2);
INSERT INTO G1211 VALUES (6,'深圳市',2);
INSERT INTO G1211 VALUES (7,'沙河镇',3);
INSERT INTO G1211 VALUES (8,'中关村',4);
INSERT INTO G1211 VALUES (9,'天河区',5);
INSERT INTO G1211 VALUES (10,'福田区',6);