Why does CONNECT BY LEVEL on a table return extra rows?

后端 未结 4 1596
故里飘歌
故里飘歌 2020-12-30 05:19

Using CONNECT BY LEVEL seems to return too many rows when performed on a table. What is the logic behind what\'s happening?

Assuming the following table:

<         


        
4条回答
  •  死守一世寂寞
    2020-12-30 05:58

    You can use technique below to overcome this issue:

    select id, level as lvl
       from a
          left outer join (select level l from dual connect by level <= 2) lev on 1 = 1
    order by id
    

提交回复
热议问题