wx2

SQL replacement for Recursive CTE

蹲街弑〆低调 提交于 2019-12-12 03:25:51
问题 I have a table Test which contains TEST ---- tablename|columnvalue|rankofcolumn A|C1|1 A|C2|2 A|C3|3 A|C4|4 B|CX1|1 B|CX2|2 C|CY1|1 C|CY2|2 C|CY3|3 I want to generate the path along with other columns as follows RESULT ---- tablename|columnvalue|rankofcolumn|path A|C1|1|C1 A|C2|2|C1->C2 A|C3|3|C1->C2->C3 A|C4|4|C1->C2->C3->C4 B|CX1|1|CX1 B|CX2|2|CX1->CX2 C|CY1|1|CY1 C|CY2|2|CY1->CY2 C|CY3|3|CY1->CY2->CY3 As per this question, I can use recursive CTE to achieve this WITH r ( tablename,