strange result about rownum in the oracle sql

42 Views Asked by At

this is a table called nums.

| id |
| 1  |
| 2  |
| 3  |

I execute the SQL:

with s as (
 select id, rownum rn from nums
)

select s1.id id1,s1.rn rn1, s2.id id2, s2.rn rn2 
from s s1 join s s2 
on s1.id != s2.id

the result is :

|id1|rn1|id2|rn2|
|1  |1  |2  |2  |
|1  |1  |3  |3  |
|2  |4  |1  |1  |
|2  |4  |3  |3  |
|3  |4  |1  |1  |
|3  |4  |2  |2  |

why there is the num 4 in the result?

0

There are 0 best solutions below