Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 03 Sep 2002 @ 16:25:53 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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


     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023