How can I separate one column into multiple column?

How can I separate one column into multiple column?
This is what I have:
BUYER_ID ATTRIBUTE_NAME ATTRIBUTE_VALUE
0001 PHONE_NUMBER 555-555-0001
0001 EMAIL [email protected]
0001 CURRENCY USD
0002 PHONE_NUMBER 555-555-0002
0002 EMAIL [email protected]
0002 CURRENCY USD
0003 PHONE_NUMBER 555-555-0003
0003 EMAIL [email protected]
0003 CURRENCY CAD
This is what I would like to have:
BUYER_ID PHONE_NUMBER EMAIL CURRENCY
0001 555-555-0001 [email protected] USD
0002 555-555-0002 [email protected] USD
0003 555-555-0003 [email protected] CAD
Any help would be greatly appreciated.

This is another solution. Suppose your actual table's name is test(which has the redundant data). create a table like this:
CREATE TABLE test2 (BUYER_ID number(10),PHONE_NUMBER varchar2(50),EMAIL varchar2(50),CURRENCY varchar2(50));
then you will type this procedure:
declare
phone_number_v varchar2(50);
EMAIL_v varchar2(50);
CURRENCY_v varchar2(50);
cursor my_test is select * from test;
begin
for my_test_curs in my_test loop
select ATTRIBUTE_VALUE INTO phone_number_v from test
where person_id=my_test_curs.person_id
and attribute_name ='PHONE_NUMBER';
select ATTRIBUTE_VALUE INTO EMAIL_v from test
where person_id=my_test_curs.person_id
and attribute_name ='EMAIL';
select ATTRIBUTE_VALUE INTO CURRENCY_v from test
where person_id=my_test_curs.person_id
and attribute_name ='CURRENCY';
INSERT INTO test2
VALUES (my_test_curs.person_id,phone_number_v,EMAIL_v,CURRENCY_v);
END LOOP;
END;
Then you will create your final table like this:
create table final_table as select * from test2 where 1=2;
After that write this code:
INSERT ALL
into final_table
SELECT DISTINCT(BUYER_ID),PHONE_NUMBER,EMAIL,CURRENCY
FROM TEST2;
If you have a huge amount of data in your original table this solution may take a long time to do what you need.

Similar Messages

  • How can I seperate one string into multiple strings using PowerShell?

    New to PowerShell...how can I read/separate parts of a file name? For instance if I have a file name like "part1_part2_part3_part4.xls", how to separate this file name to four different parts? So I basically want to go from that file name,
    to four different strings like part1, part2, part3, and part4...as four separate strings. How can I get this done in PowerShell?
    Thanks

    You can try something like this
    PS> (Get-ChildItem part1_part2_part3_part4.xls).BaseName.Split('_')

  • How do I separate a PDF into multiple PDFs using Adobe PDF Pack?

    How do I separate a pdf into multiple pdfs using AdobePack?
    [Title edited to reflect actual product name... Mod]

    I do not find "AdobePack" when I look at the list of forums https://forums.adobe.com/welcome
    What is the exact name of the program you are using... Acrobat, or are you using the online version at Acrobat.com?
    ADDED... found Adobe PDF Pack (read only) so will move this message

  • How can i put one scene into JPanel of the swing?

    how can i put one scene into JPanel of the swing?

    980571 wrote:
    ty for the information but i have a problen with JFXpanel when i try to into a panel it doesnt display insideSorry to hear that. If you want assistance with the code, feel free to post the relevant parts of it. Make sure to use \ tags when you do.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Two sets of faces have merged into one. How can I separate them back into two groups or delete the bunch

    Two different sets of faces have merged into one under one name. How can I separate them back or delete the bunch?

    Look at Steve MacGuire's helpful article:  http://samsoft.org.uk/iTunes/grouping.asp  It explains how to solve this much better than I can.

  • How can i separate 4 devises into individual accounts?

    I have 1 x iPhone 4, 2 x iPhone 4S and 1 x iTouch 4th Gen all on one iTunes, iCloud and the same Apple iD. How can i separate them into having their own individual accounts??? Please help we are all recieving each others txt messages and contacts lists.

    Export your images as png, jpg or tiff. As most users can see these formats. Tiff would be the largest format so it will take up more of your email limit and will be slower to send and receive. But will keep most of the features editable.
    Png like tiff supports transparency, whereas jpg lacks majority of the features found in the other formats but can be highly compressible. However it does so by throwing away data. So each time the file is opened and saved more data is thrown away, if repeated enough times the file is no longer usable.
    Png and jpg are great for viewing inside a web browser or email program. Tiff can be viewed in a image viewer normally associated when accessing the file from windows explorer or mac's finder.
    Once the files are exported, most email programs can select the images as attachments.

  • HT1535 Once I have songs in mt ipod, How can I separate the songs into folders?

    Once I have songs in my IPod, how can I separate them into folders such as favorites, etc.?

    That sort of thing is best done in iTunes. And by "folders", I assume you mean Playlists.
    In iTunes, you can create Playlists and then sync those to your iPod. The music will still be listed by artist, album etc,. but if you go into the Playlists menu, you will see the songs grouped by Playlists, according to your choices.
    As you mentioned favourites; on your iPod you can give a song a star rating, from one to five stars. It's possible to create a Smart Playlist in iTunes which will automatically add (for example) three, four and five star rated songs to a Playlist, but not the songs with no rating or just one or two stars.
    So if you were listening to a song and decided there and then to give it a four-star rating, then at the next Sync with your iTunes Library, that song would be added to your Smart Playlist which is then also included on the iPod. (In theory, it should go into that Playlist on your iPod without connecting to your iTunes Library, but that doesn't always work.)

  • During import, how to auto split one project into multiple albums based on date?

    I believe I've done enough aperture reserach to get all my terminology right, so here goes...
    I've created a file structure within the aperture inspector the the tune of: 
    Year [folder], Type of event (Occasion, special occasion, holiday, vacation) [folder], Project (Wedding), Album (i.e. Day 1, Day 2 or Pre wedding week, event, honeymoon).
    I also have entire months with 7 or 8 pictures each day, that are of the same type/project (random dog pictures) but are distinctly different days (albums - day in park, in bed at night, watching movie). 
    My question is, can I import one project with multiple albums already created based on the date they're taken.  As I can see it, all I can do is split individual projects automatically by date.  But what if one project is over one month, but has multiple distinct days that would be ideal for albums?  One more example.  We did a trip to San Fran.  One day was touring the city, one day was a concert, another day was touring the city.  All one project, but 3 different albums (in my mind).  I had to import as one project, then separately go in and make albums.  I would like that done automatically.
    My suspicion is that I can not natively do this within aperture, and that I would need something called an "applescript."  I haven't done any reserach into that area, so if that's the case and you know where I can find a script that would do this, I'd appreciate the help. 
    Sorry for the wordiness, just wanted to be clear.  Thanks for any and all help!

    Hi,
    You need to create a new requirement in tcode VOFM for that, together with your ABAP consultant. This requirement will be used in copy contol.
    http://saptechsolutions.com/pdf/VOFMCopyRequirementRoutines.pdf
    MdZ

  • Split one row into multiple columns

    Hi,
    Data in one CLOB column in a table storing with delimiter, ##~~##. Ex. ##~~##abc##~~##defgh##~~##ijklm##~~##nopqr (data starts with delimiter). Please help me to split the data into multiple rows like below and it should be in the same order.
    abc
    defgh
    ijklm
    nopqr
    I am using Oracle 11g.
    Thanks.

    Thanks Hoek for your response. Before posting my question in the forum, I tried similar query. It is working with one character as delimiter.
    with test as (select 'ABC,DEF,GHI,JKL,MNO' str from dual )
    select regexp_substr (str, '[^,]+', 1, rownum) split
    from test
    connect by level <= length (regexp_replace (str, '[^,]+')) + 1;
    Above query is giving correct result by fetching 5 rows. I have modified the query like below...
    with test as (select 'ABC,,,DEF,,,GHI,,,JKL,,,MNO' str from dual )
    select regexp_substr (str, '[^,,,]+', 1, rownum) split
    from test
    connect by level <= length (regexp_replace (str, '[^,,,]+')) + 1;
    Above query resulting 13 rows and last 8 rows are nulls. Number of null rows are increasing, if I increase number of characters in delimiter. Could you please tell me how to avoid those null rows.
    Thanks.

  • How can I break one track into several tracks

    Hello all,
    Im new to Mac and garageband, My problem is when i spin a full set of lets say 2 hours into garage band as 1 track, how can I go back and break that 1 track into several tracks so when I make a cd people can change from track to track instead of listening to one track all the way through.
    Thanks in Advance

    Ok now that I chose the region how would I export it?
    Just select "export".
    And Also Do I have to export each track one by one to itunes?
    Since you want to burn a CD, you need several sound files, and GB only exports one file at a time.

  • How can I copy one sheet into another spreadsheet or another file?

    I am trying to copy a sheet from one file into another.  Is that possible in Numbers?

    Open both documents.
    Click on the sheet icon of the sheet you want to Copy fom the Source document. Copy
    Switch to the second document.
    Click on the icon of one of the Sheets on that document. Paste.
    The copied sheet (and its contents) will be pasted into the list immediately below the selected sheet.
    Regards,
    Barry

  • To split a column into multiple columns

    Hi,
    I have column and i want to split it into three columns as shown below given inputs and required outputs. I have written this query to get P_1, and p_2 but dont know how to get p_3.
    SELECT ADDRESS,SUBSTR(ADDRESS,1, INSTR(ADDRESS,' ')-1) P_1
         ,SUBSTR(ADDRESS, instr(address,' ',-1)+1) P_2
         FROM TT
    Input:
    ADDRESS     
    1 AVENUE OF THE AMERICAS     
    2 NORTH CAROLINE STREET EAST     
    236 TURPENTINE ROAD COOPER CREEK     
    REQUIRED OUTPUT
    P_1     P_2     P_3     
    1     AMERICAS     AVENUE OF THE
    2     EAST     NORTH CAROLINE STREET
    236     CREEK     TURPENTINE ROAD COOPER
    Thanks in advance

    If you're on 10g or 11g you can do something like this ...
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 4 21:18:07 2008
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    column p_1 format a3
    column p_2 format a10
    column p_3 format a30
    with data as
    select '1 AVENUE OF THE AMERICAS' as ADDRESS from dual union all
    select '2 NORTH CAROLINE STREET EAST' as ADDRESS from dual union all
    select '236 TURPENTINE ROAD COOPER CREEK' as ADDRESS from dual
    select
      regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\1' ) as p_1 ,
      regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\3' ) as p_2 ,
      regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\2' ) as p_3
    from
      data
    P_1 P_2        P_3
    1   AMERICAS   AVENUE OF THE
    2   EAST       NORTH CAROLINE STREET
    236 CREEK      TURPENTINE ROAD COOPER
    3 rows selected.
    -- or try this shorter version --
    with data as
    select '1 AVENUE OF THE AMERICAS' as ADDRESS from dual union all
    select '2 NORTH CAROLINE STREET EAST' as ADDRESS from dual union all
    select '236 TURPENTINE ROAD COOPER CREEK' as ADDRESS from dual
    select
      regexp_replace( address, '^([^ ]+).*', '\1' ) as p_1 ,
      regexp_replace( address, '.*?([^ ]+)$', '\1' ) as p_2 ,
      regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\2' ) as p_3
    from
      data
    P_1 P_2        P_3
    1   AMERICAS   AVENUE OF THE
    2   EAST       NORTH CAROLINE STREET
    236 CREEK      TURPENTINE ROAD COOPER
    3 rows selected.See SQL Snippets: SQL Features Tutorials - Regular Expressions if you're unfamiliar with regular expressions.
    If you can't / don't want to use regular expressions then you'll need to settle for a more boring approach like this one.
    with data as
    select '1 AVENUE OF THE AMERICAS' as ADDRESS from dual union all
    select '2 NORTH CAROLINE STREET EAST' as ADDRESS from dual union all
    select '236 TURPENTINE ROAD COOPER CREEK' as ADDRESS from dual
    select
      substr( address, 1, instr( address, ' ' ) - 1 ) as p_1 ,
      substr( address, instr( address, ' ', - 1 ) + 1 ) as p_2 ,
      substr
      ( address,
        instr( address, ' ', + 1 ) + 1,
        instr( address, ' ', - 1 ) - instr( address, ' ' ) - 1
      ) as p_3
    from
      data
    P_1 P_2        P_3
    1   AMERICAS   AVENUE OF THE
    2   EAST       NORTH CAROLINE STREET
    236 CREEK      TURPENTINE ROAD COOPER--
    Joe Fuda
    SQL Snippets

  • Split 1 column into multiple columns

    Hi
    How can we acheive this in Sql:
    Col 1
    abc def ghi jkl
    convert to:
    Col 1
    Col 2
    Col 3
    Col 4
    abc
    def
    ghi
    jkl
    Royal Thomas

    The best approach is to NOT split them out into individual columns... It violates the 1st normal form...
    Under first normal form, all occurrences of a record[sic] type must contain the same number of fields[sic].
    First normal form excludes variable repeating fields[sic] and groups.
    The better approach is to split them into rows, in their own table, with a foreign key reference back to the table you are pulling them away from.
    If you check my 1st post you'll see that I split the string with a function. That same a function can be used to populate the new table.
    Something along these lines...
    IF OBJECT_ID('tempdb..#BadOldDesign') IS NOT NULL
    DROP TABLE #BadOldDesign;
    CREATE TABLE #BadOldDesign (
    ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
    ListOfCodes VARCHAR(100) NOT NULL
    INSERT #BadOldDesign (ListOfCodes) VALUES
    ('abc htr tbj yfd hjk mth'),
    ('bbb hyt tbj vyk hjk htd'),
    ('vvv nud'),
    ('yyy hyn tbj bdr '),
    ('htr htf tbj yfd hjk mko'),
    ('kio bhn tbj bjd hjk'),
    ('byd loj tbj yfd hjk cds');
    SELECT * FROM #BadOldDesign bod
    IF OBJECT_ID('tempdb..#ShinyNewTable') IS NOT NULL
    DROP TABLE #ShinyNewTable;
    SELECT
    bod.ID,
    sc8.ItemNumber,
    sc8.Item
    INTO #ShinyNewTable
    FROM
    #BadOldDesign bod
    CROSS APPLY dbo.SplitCSVToTable8K(bod.ListOfCodes, ' ') sc8;
    ALTER TABLE #ShinyNewTable ALTER COLUMN id INT NOT NULL;
    GO
    ALTER TABLE #ShinyNewTable ALTER COLUMN ItemNumber INT NOT NULL;
    GO
    ALTER TABLE #ShinyNewTable ADD CONSTRAINT pk_ShinyNewTable PRIMARY KEY CLUSTERED (ID, ItemNumber);
    SELECT * FROM #ShinyNewTable snt
    The dbo.SplitCSVToTable8K function that I'm using can be found here... http://www.sqlservercentral.com/articles/Tally+Table/72993/
    HTH,
    Jason
    Jason Long

  • How can I Make one column into Multiple columns

    Id
    SCM-01-015
    SCM-01-020
    SFA-02-021
    SFC-02-042
    STB-03-035
    STP-04-167
    SVF-06-150
    I want the output like this
    Id 01 02 03 04 06
    SCM-01-015 5
    SCM-01-020 10
    SFA-02-021 15
    SFC-02-042 15
    STB-03-035 20
    STP-04-167 50
    SVF-06-150 5
    thank you in advance

    Hi,
    801668 wrote:
    Id
    SCM-01-015
    SCM-01-020
    SFA-02-021
    SFC-02-042
    STB-03-035
    STP-04-167
    SVF-06-150
    I want the output like this
    Id 01 02 03 04 06
    SCM-01-015 5
    SCM-01-020 10
    SFA-02-021 15
    SFC-02-042 15
    STB-03-035 20
    STP-04-167 50
    SVF-06-150 5
    thank you in advanceWhenever you post formatted text (such as query output) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
    Do you want output something like this, which is from the scott.emp table?ENAME ANALYST CLERK MANAGER PRESIDENT SALESMAN
    ALLEN 1600
    JONES 2975
    FORD 3000
    CLARK 2450
    MILLER 1300
    SMITH 800
    WARD 1250
    MARTIN 1250
    SCOTT 3000
    TURNER 1500
    ADAMS 1100
    BLAKE 2850
    KING 5000
    JAMES 950
    (ALLEN is a SALESMAN, JONES is a MANAGER, ..., JAMES is a CLERK.)
    If so, do a pivot, somehting like this:SELECT     ename
    ,     MIN (CASE WHEN job = 'ANALYST' THEN sal END)     AS analyst
    ,     MIN (CASE WHEN job = 'CLERK' THEN sal END)     AS clerk
    ,     MIN (CASE WHEN job = 'MANAGER' THEN sal END)     AS manager
    ,     MIN (CASE WHEN job = 'PRESIDENT' THEN sal END)     AS president
    ,     MIN (CASE WHEN job = 'SALESMAN' THEN sal END)     AS salesman
    FROM     scott.emp
    GROUP BY ename
    Always say which version of Oracle you're using.
    The query above will work in Oracle 8.1 or higher, but starting in Oracle 11 there's a better way:  SELECT ... PIVOT.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I make one cell search multiple other cells for a string of text and return whether or not the string appeared in the cells searched?

    https://www.icloud.com/iw/#numbers/BAI31boMQXsGKc8NH22BlqWRzbs8PdgWBs-F/2014-15_ Curriculum_Planning_w_CCSS_(Web_Shared)
    My document is above, if anyone wants to help this crazy teacher invent a better lesson planner.
    Here's my predicament.  The state in which I teach requires teachers to keep up with which of the Common Core State Standards (CCSS) their instruction is addressing and when the standards were addressed.  I got the bright idea to do this through a spreadsheet in Numbers because our school is getting iPads this year, so it'd be pretty sweet to be able to assemble all of my lesson plans in one massive spreadsheet.  On the "AP Lesson Plans" sheet, I've got a few weeks worth of lesson plans entered in.  I'm planning on going in and using the drop-down menu next to each lesson plan to add all the CCSS on a per-day basis.  This is simple enough, but here's where I run into a problem.
    I want the "AP Standards" sheet to concatenate, in cells D3 through G76, the dates on which a standard was covered.  What I need is some way for, say, Cell D3 to look at the table on the "AP Lesson Plans" sheet and concatenate the dates of every lesson which has the standard in column A (In this instance, RL.11-12.1).  At the end of the day, the functionality I need is that I can enter my lessons and CCSS on the "AP Lesson Plans" sheet and go to the other sheet and see a summary of which standards have been addressed, when, and how often.
    If that's as clear as mud, well, I teach literature, not technical writing, so my apologies.  I'm more at home with Jonathan Swift than spreadsheets.  I'll gladly help you help me if you'd let me know what you need to know.  Oh, and to illustrate my knowledge level (just enough to be dangerous), I've left you the formula of my best stab at making cell D3 behave as desired.  It's the gray box on the "AP Standards" sheet.  Yikes.

    Hi Arrdenet,
    Congratulations on the nested IFs. I haven't tested that formula, but it is impressive. It will be very difficult to debug if it doesn't work, and I think it would make Numbers very slow.
    Here is a different approach. After you enter all the CCSS, add another column with HLOOKUP.
    Edit:
    B2 (and Fill Down)
    A2 (and Fill Down)
    =IFERROR(HLOOKUP(A$1,C2:E2,1,0),"")
    HLOOKUP looks for the value in A1 in all the CCSS columns.
    IFERROR is to stop the error triangles appearing and returns "" (NULL) instead.
    Then sort by column A.
    Not a complete answer, but it might get you started.
    Regards,
    Ian.

Maybe you are looking for

  • Batch job failing with INVALID_STARTDATE exception

    Hello Experts, our batch  job  runs 17th minute of every hour on daily basis.It is running successfully from 00:17 AM to 20:17 PM and gets completed within 1 hour for every run. But when it is starting 21:17PM, it keeps on running for next 5-6 hours

  • How do I use Time Capsule as an external hard drive?

    How do I use Time Capsule as an external hard drive? I want to remove photos & music from my laptop and store them in Time Capsule only.

  • Redirect HTTPS traffic to HTTP in Tomcat

    Hi, We are running SAP BI Platform 4.0 SP2 Patch 7, which runs on top of Tomcat 6. We have succesfully configured our iPads to connect to our SAP BusinessObjects server using HTTPS in internet. We have an application proxy that handles HTTPS and send

  • How to get path

    Hello How do I get the current path an object is executing from? This is for a simple test. I have a file I want to open up within my object. That file is being copied to the .class directory where my object is. I just want to figure out how to use s

  • Cancelled by On-Line order

    Well, I just cancelled my on-line order that was to ship on the 13th. After reading post here and reviews in the media I think I will wait until the next generation iPhone. The reports of low volume and other missing phone functions have scared me of