Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2016
    Posts
    1

    Unanswered: Splitting one row into mutiple rows

    Hi,

    I think this should be relatively simple, but i can't for the life of my figure out how to do this.

    I've got 4 Columns

    Symbol , Price , Vol , Date
    Z , 10 , 1 , 1/1/2015
    Y , 5 , 3 , 1/1/2015
    X , 7 , 2 , 1/1/2016

    I just want to split the rows based on the vol column to get

    Symbol Price Vol Date
    Z , 10 , 1 , 1/1/2015
    Y , 5 , 1 , 1/1/2015
    Y , 5 , 1 , 1/1/2015
    Y , 5 , 1 , 1/1/2015
    X , 7 , 1 , 1/1/2016
    X 7 1 1/1/2016


    I'm thinking I should use an outer join of sorts on one side but i can't remember how to repeat rows.

    Any ideas?

    Thanks.

  2. #2
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    530
    procedure
    read table where vol>1
    cursor 1
    for each line
    cursor 2 with volume
    insert lines with volume=1
    end cursor 2
    modify cursor with volume=1
    end cursor
    F. Celaia
    DBA Oracle/MS-SQL/MySQLSybase/DB2/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •