![](//teradataforum.com/imgs/ptdfw1.gif) |
![](//teradataforum.com/imgs/ptdfw2.gif) |
Archives of the TeradataForum
Message Posted: Tue, 03 Sep 2002 @ 16:25:53 GMT
Subj: | | Re: Splitting records depending on Qty |
|
From: | | Geoffrey Rommel |
| I want to split the records depends up on qty.... I need to done only with sql. | |
Well, here's a brute-force approach.
select itemno, itemname, itemtype, itemqty,
k.seq_no
from sreya,
(select csum(1, calendar_date) seq_no
from sys_calendar.calendar) k
where k.seq_no <= itemqty
order by 1,5;
*** Query completed. 12 rows found. 5 columns returned.
*** Total elapsed time was 1 second.
itemno itemname itemtype itemqty seq_no
------ -------- -------- ------- -----------
1 aaaaaa C 6 1
1 aaaaaa C 6 2
1 aaaaaa C 6 3
1 aaaaaa C 6 4
1 aaaaaa C 6 5
1 aaaaaa C 6 6
2 BBBBBB K 3 1
2 BBBBBB K 3 2
2 BBBBBB K 3 3
3 CCCCCC L 2 1
3 CCCCCC L 2 2
4 DDDDDD M 1 1
| |