使用SQL为链接的行创建组ID

时间:2018-02-08 16:11:12

标签: sql graph

在SQL中,是否有办法为“链接组”创建ID?

Source Table

+----+-----+
| Id |  Id |
+----+-----+
|  1 |   2 |
|  1 |   3 |
|  2 |   3 |
|  4 |   5 |
+----+-----+

Desired Result Table
+----+-----+-----------+
| Id |  Id |  Group Id |
+----+-----+-----------+
|  1 |   2 | A         |
|  1 |   3 | A         |
|  2 |   3 | A         |
|  4 |   5 | B         |
+----+-----+-----------+

见图

Also see Diagram

0 个答案:

没有答案