SQL如何从表中反复查询数据?

2025-03-26 01:23:19
推荐回答(1个)
回答1:

如下语句,其中,id必须要连续的,如果没有此列,或是不连续,用ROW_NUMBER()生成一个。

SQL code?with table1 as(select 1 id, 'A1' c1 union allselect 2 id, 'A2' union allselect 3 id, 'A3' union allselect 4 id, 'A4' union allselect 5 id, 'A5')select a.c1, b.c1, c.c1 from table1 aleft join table1 b on a.id