I tried to generate data using the "by level" expression.
I want to generate GROUPNR, starting with 1, meanwhile each group contains 4 items with nr 1 to 4
This is, how the result should look like
groupnr itemnr
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
I used this statement, but I have no idea how to handle the nvl2 or other functions to get the right values
select level, floor(level+3/4) GROUPNR, nvl2(0, mod(level,4),4) ITEMNR
from dual
connect by level <= 25;
The result of the select is:
groupnr itemnr
1 1
1 2
1 3
1 0
2 1
2 2
2 3
2 0
4 1
Please give me a hint how to modify the level to get the right values. Bye Jochen