updated multi-column seq

Hi all

Can someone help me to update my emp table.

It's my orginal table
SQL> select * from emp_addr order by 1, 2;

EMP_NAME        EMP_ADD              CO_NAME
--------------- -------------------- --------------------
ADAM            803, Coton Gren rd   hl bank
ADAM            803, Coton Gren rd   hl bank
ADAM            Defu Lane 10         can bank
JACK            Ubi Rd 4             bank ofshore
JON             78, Sin Ming Dr      bank ofshore
JON             78, Sin Ming Dr      bank ofshore
SAM             15, Telok Kurau Rd   bank
SAM             205,Alexandra Rd     bank

8 rows selected
the output should look like
SQL> select * from emp_addr order by 1, 2;

EMP_NAME        EMP_ADD              CO_NAME
--------------- -------------------- --------------------
ADAM_1          803, Coton Gren rd   hl bank
ADAM_1          803, Coton Gren rd   hl bank
ADAM_2          Defu Lane 10         can bank
JACK_1          Ubi Rd 4             bank ofshore
JON_1           78, Sin Ming Dr      bank ofshore
JON_1           78, Sin Ming Dr      bank ofshore
SAM_1           15, Telok Kurau Rd   bank
SAM_2           205,Alexandra Rd     bank

8 rows selected
Here ADAM_1 is repeated twice because EMP_ADD and CO_NAME twice.
Its a group of EMP_ADD and CO_NAME

Thank you

Rgds
Saaz
SQL> select * from t
  2  /

NAME                 ADDRESS            COMP
-------------------- ------------------ ------------
ADAM                 803, Coton Gren rd hl bank
ADAM                 803, Coton Gren rd hl bank
ADAM                 Defu Lane 10       can bank
JACK                 Ubi Rd 4           bank ofshore
JON                  78, Sin Ming Dr    bank ofshore
JON                  78, Sin Ming Dr    bank ofshore
SAM                  15, Telok Kurau Rd bank
SAM                  205,Alexandra Rd   bank

8 rows selected.

SQL> update t
  2     set name = (    select name||rno name
  3               from (select row_number() over(partition by name order by name) rno,
  4                            t.*
  5                       from (select distinct name, address, comp from t) t) t1
  6              where t.name = t1.name
  7                and t.address = t1.address
  8                and t.comp = t1.comp)
  9  /

8 rows updated.

SQL> select * from t
  2  /

NAME                 ADDRESS            COMP
-------------------- ------------------ ------------
ADAM1                803, Coton Gren rd hl bank
ADAM1                803, Coton Gren rd hl bank
ADAM2                Defu Lane 10       can bank
JACK1                Ubi Rd 4           bank ofshore
JON1                 78, Sin Ming Dr    bank ofshore
JON1                 78, Sin Ming Dr    bank ofshore
SAM1                 15, Telok Kurau Rd bank
SAM2                 205,Alexandra Rd   bank

8 rows selected.

Tags: Database

Similar Questions

  • UPDATED MULTI-COLUMN ORA-00001

    When I try to update the 3 columns to s_cust with s_upd_fault data I get ORA-00001: unique constraint (DaveyB.FLT_REF) violated.

    I'm not sure why this is and how to fix it.

    I hope you can help.

    CREATE TABLE s_upd_fault AS
    SELECT  11111 AS s_fault_number,
                'David Bryan' AS s_full_name,
                'Closed' AS s_fault_status
                --'' AS t_adv_notes,
                --'' AS t_adv_fault_status
    FROM DUAL UNION ALL
    SELECT 11112, 'James Smith', 'Open' FROM DUAL UNION ALL
    SELECT 11113, 'Claire Smith', 'Closed' FROM DUAL UNION ALL
    SELECT 11114, 'Jenny Row', 'Closed' FROM DUAL UNION ALL
    SELECT 11115, 'Stan Lee', 'Closed' FROM DUAL UNION ALL
    SELECT 11116, 'John Steves', 'Closed' FROM DUAL UNION ALL
    SELECT 11117, 'James James', 'Open' FROM DUAL UNION ALL
    SELECT 11118, 'David David', 'Open' FROM DUAL UNION ALL
    SELECT 11119, 'Peter Peter', 'Open' FROM DUAL
    ;
    
    /* TEST DATA*/
    --INSERTS TODAYS DATA INTO THE TABLE
    INSERT INTO s_cust (s_fault_number, s_full_name, s_fault_status) ( 
    SELECT      s_fault_number, s_full_name, s_fault_status
    FROM        s_fault
    )
    ; 
    
    /*CREATES A TABLE TEMPLATE TO STORE THE DATA*/ 
    CREATE TABLE s_cust (
    s_fault_number  VARCHAR(20) CONSTRAINT flt_ref PRIMARY KEY,
    s_full_name     VARCHAR2(15),
    s_fault_status  VARCHAR2(10),
    t_adv_notes     VARCHAR2(20),
    t_adv_fault_status VARCHAR2(30),
        CHECK (s_fault_status IN ('Open', 'Closed'))  --VALIDATION
    );
    
    
    --UPDATE THE COLUMNS WITH NEW DATA
    UPDATE  
        s_cust 
    SET 
    (   s_fault_number,
        s_full_name,
        s_fault_status
    ) = 
    (   
        SELECT  s_fault_number,
                s_full_name,
                s_fault_status
        FROM    s_upd_fault
        WHERE   s_fault_number = '11111'
    )
    Edited by: DaveyB October 8, 2009 12:38

    Hello

    UPDATE
        s_cust
    SET
    (   s_fault_number,
        s_full_name,
        s_fault_status
    ) =
    (
        SELECT  s_fault_number,
                s_full_name,
                s_fault_status
        FROM    s_upd_fault
        WHERE   s_fault_number = '11111'
    )
    

    Because the above query is updated all the lines with s_fault_number as '11111', and since it is a primary key, you cannot update this value to more than one line.

    I guess you could want to do that

    UPDATE
        s_cust  s_cust
    SET
    (   s_fault_number,
        s_full_name,
        s_fault_status
    ) =
    (
        SELECT  s_fault_number,
                s_full_name,
                s_fault_status
        FROM    s_upd_fault suf
        WHERE   s_cust. s_fault_number = suf.s_fault_number
    )
    where s_fault_number = '11111'
    

    If you want to update the entire column and then withdraw where s_fault_number = '11111'

    Concerning
    Anurag Tibrewal.

  • Compare multiple columns and update a column based on the comparison

    Hi all

    I have to update the column STATUS of the slot structure of the table.

    Status should be 'P' if all the columns count are equal on the other should be "F".

    The value of the column can be "NA'. If the value is NA, then avoid this comparison column; compare only other 3 columns.

    My output should look like below.

    State of cnt1, cnt2 cnt3 ID cnt4

    1   4       4       4     4       P

    2   4       5       4     4       F

    3 4 4 NA 4 P

    NA 4 4 3 4

    I tried with the statemnt with BOX WHEN conditions and DECODE UPDATE, but could not succeed, can someone please help

    To do this, if you use my statement in response #11 box (Re: Re: comparison of multi-column and update a column based on the comparison of)

  • InDesign, Import XML, switching to and from possible design multi-column?

    I have a question that may or may not require a script solution. I have a data source external generation text referenced XML file that I will not flow into a book. Normally, the book is a two-column layout, but there are illustrations (and sometimes pieces of explanatory text) which should cover both columns. I've built examples of use of reflow smart text for simple and updated column in multi-column page layout. Using one of these with the active smart text reflow works beautifully.

    Ideally, I would like to a XML tag that says "start spanning two columns now", inserts a large illustration (could also be a piece of text however) and another that says "return to normal 2 columns. I did a number of experiments (all unsuccessful) I can't seem to get a working solution. I really like the XML import, but if this is not possible, I'm willing to look at other approaches.

    Has anyone had a similar problem?

    As a gross illustration...

    Lorem ipsum dolor sit amet, adipiscing elit computer.

    CRAs quis ligula EST. SED dictum erat an EST porta in

    dignissim nisl ultrices. In and convallis elit. Curabitur pretium

    < HYPOTHETICAL_SPAN > magna EU ornare, tellus faucibus total, placerat vitae arcu fringilla

    Nulla non sapien ligula. Vestibule vel mauris and pellentesque erat

    Nunc. Vestibule total ac nulla ornare EU ultricies sapien tincidunt < / HYPOTHETICAL_SPAN >

    so. In metus, id erat auctor gravida dignissim

    eget dignissim erat dictum nisl eleifend porta an EST in

    Harold

    Just to be clear, when you say:

    I have a data source external generation text referenced XML file that I will not flow into a book.

    you mean import XML, not the import of text containing the tag of InDesign, correct?

    Ideally, I would like to a XML tag that says "start spanning two columns now", inserts a large illustration (could also be a piece of text however) and another that says "return to normal 2 columns. I did a number of experiments (all unsuccessful) I can't seem to get a working solution. I really like the XML import, but if this is not possible, I'm willing to look at other approaches.

    Can't you just a tag that maps to a paragraph style that allows to span columns?

  • When Fire Fox support (again!) for display of multi column (and navagable) Favorites (bookmarks)?

    I always use rev 31. This is the last version that is compatible with the add-in on, "Multicolumn Bookmarks 1.5', I have several brands of books collected over the years and the single column format is frustrating and not helpful."

    Asked to provide a current version, which is compatible with "MultiColumn Bookmarks 1.5' Fire Fox, or provide a favorite navigable multi-column as option display in a near future program revision Fire Fox.»

    Sincerely,

    Pierre Arnold

    Sorry, to complete the thought:

    (1) install Stylish from the Mozilla Add-ons site

    https://addons.Mozilla.org/firefox/addon/stylish/

    (2) then back to the user page of style to get the style (the button should be green instead of blue right here)

    https://userstyles.org/styles/119797/bookmarks-menu-in-multiple-columns

  • How to customize the scroll and symbols bars in a multi column list box

    Hello

    I have recently been design FP and have gotten to a scroll bar in a multi column list box.

    How can I change the decals and colors of the scroll bar as I can't seem to change or select all components of it within the control editor.

    I would change the arrow buttons and arrow the cursor with a custom sticker and have a solid track. In adition to that, I would like to change some of the symbols or add my own custom in the existing list.

    Is this possible to do?

    carbon32 wrote:

    Hello

    I have recently been design FP and have gotten to a scroll bar in a multi column list box.

    How can I change the decals and colors of the scroll bar as I can't seem to change or select all components of it within the control editor.

    I would change the arrow buttons and arrow the cursor with a custom sticker and have a solid track. In adition to that, I would like to change some of the symbols or add my own custom in the existing list.

    Is this possible to do?

    I don't think that you can customize parts of the scollbars.

    Here how to add symbols to a listbox control. The new index of symbols must last for 41 as the indices of standard symbols are included between 1 and 40. The size of your custom symbol must be 16 x 16.

    Ben64

  • By programming the auto scroll value multi-column list boxes?

    I have a Multi column list box control that I put off (for indication only) which is used to show the progress.

    When a profile is loaded in the list box if this profile causes the scroll bar to become active it's obviously disabled and if the user cannot scroll

    That the control is disabled, the scroll bar is also disabled is there anyway that I can programmatically on the AutoScroll scroll bar?

    Hello

    You can use the property of the listbox multicoum ' cell upper left Visible.

    If your listbox multicoloum is disabled you can put vertical cursors or something on the front and give the value of the cursor to the line/Coloum (vertical scrollbar) and Coloum for the horizontal scroll bar to the "cell upper left Visible.

    Hope this helps

    Concerning

    David

  • Is it possible particularly handy/quick to disable controls (multi-column listbox) when executing the output material associated?

    Please excuse me if the title of the post is not clear, I would try to explain what I need to do here.

    In the application, I am currently in train, UI use multi column listboxes in several places where a set value (one line) is selected, and based on the rowset / selected, relay/material are enabled to match a given configuration (which is then verified with your comments).  The problem is, I can easily rush into the user interface and make program stuttering and choke...

    I just put my finger down in one of the rows in the listbox control and drag my finger up and down the screen as a 5 year old child see a touch screen for the first time - he tries to each entry cache/buffer.  After I stop being 5 years old again I sit and listen to the click click of the relay for a bit.  One of these list boxes, I've already implemented enable and disable to pieces of code to implement the right before the digital output and solve the controls right after that feedback has been verified.  It was kind of a pain to do, so I wonder if there is an easier way to do it.

    Any idea or suggestion appreciated!

    Thank you

    -Pat

    PS - i As training until this weekend so I will probably not be quick to answer, but still thx for any info

    Use a "Mouse Up" event instead of an event of "change the value.

  • Add row in table or list multi-column

    Hello

    I discovered Labview (version 8.6) and I am trying to create a program of asquisition of data pour a shock absorber test bench.

    I collects the data and table classes in UN, AND cre a XY graph pour display a Representative force of the shock curve depending on the speed of movement of the stem. Until there all right!

    My problem is that I want that when the cycle is done en continue, new data appears on the next line instead of "crush the Report values as is currently the case. I tried with the tool 'table' and the 'multi-column list' tool but the problem is the same: How do I do?

    It happens that I have the same problem to display the curves on my XY graph, I also need help pay this problem.

    Please pour your attention and your help.

    Kind regards

    Jeremy

    PS: If my spouse VI to image the problem.

    Hello Jeremy,

    First of all, I would like to know what you mean by en run continue? If you specify normal here the double arrow d "performance, I would like to inform you that it must be used only when debugging your application, pour allow you to change values on orders without having to continually again l ' execution of your vi.

    If you want that your program runs continuously, you can add a loop around your code, with a STOP button for example to stop it.

    Then, if you get to write a single line, it is because although you creating a table 2D of your data before sending it to the node of the list property, this table is filled by a single column.

    You will find attached your slightly modified VI pour integrate a loop at the level of the acquisition.

    I used a tunnel with auto-indexation, which allows you to create a new row in the table 2D at each iteration of the loop. It's a simple way, but is not particularly the best, you can also set up your creations of table functions in the loop. In the same way, it will take maybe add functions of timing in the loop, but in your case, I think that the acquisition it even cadencera the execution of the loop.

    The report will be completed once you have clicked the STOP button.

    This solution of hoping to match your need.

    Kind regards

  • Update multiple columns from multiple tables in a single UPDATE request

    Hello

    I'm trying to figure if I'm heading in the right direction.

    I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.

    Scenario 1

    UPDATE Table2, Table 3
    SET T2.Column1 = T1.Column1 
    ,T2.Column2 = T1.Column2
    ,T3.Column2 = T1.Column2
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T1.id = T2.id
    and T1.id = T3.id
    
    

    Scenario 2

    UPDATE Table3
    SET T3.Column1 = T1.Column1 
    T3.Column2 = T1.Column2
    ,T3.Column3 = T2.Column3
    ,T3.Column4 = T2.Column4
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T3.id = T1.id
    and T3.id = T2.id
    
    

    Hello

    For scenario 1, you must write separate instructions UPDATE table2 and table3.

    To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.

    ENGAGE only when two tables have been changed.

    You can write a procedure or an INSTEAD OF trigger to do all this.

    For scenario 2, you can reference many tables that you need when new table3.  It might be more efficient and simpler to use the MERGER rather than UPDATED.  For example:

    MERGE INTO table3 dst

    WITH THE HELP OF)

    SELECT t1.id

    t1.column1

    t1.column2

    t2.column3

    t2.column4

    FROM table1 t1

    JOIN table2 t2 ON t1.id = t2.id

    )             src

    WE (dst.id = src_id

    WHEN MATCHED THEN UPDATE

    SET dst.column1 = src.column1

    dst.column2 = src.column2,

    dst.column3 = src.column3,

    dst.column4 = src.column4,

    ;

  • How to update exists column on the table with the exact number and auto increment

    Hello

    I have a table with more than 10 million rows and there is a column called 'number_zaq', I want to update this column on line frist from 2000 and + 1 for the next all ranks.

    Update your_table

    Set number_zaq = rownum + 2000-1;

  • How to create a multi column list control?

    Currently is a single-column listbox using StdListBoxWidgetN.

    How to create a multi columns as an image list control?

    What I see a sample? or add any source?

    Thanks for help.

    You must use the TreeView Widget.

    See the example persistentlistui or wlistboxcomposite in the sdk.

  • Need logic to update the column in a Varchar table

    Hello

    Could you tell me logic below.

    I have a xx_dbc of the table where one of the Attribute1 column is varchar2 (240).

    Attribute1 has values such as

    ==================

    (AIN, PUP, GRI, NINE)

    (AIN, PUP)

    (AIN)

    (GRI, NINE)

    I have to update this column for each record with values AIN = 10, PUP = 20, GRI = 30, NINE = 40

    Columns must be updated as below

    (10,20,30,40)

    (10.20)

    (10)

    (30, 40)

    Thank you.

    Hello

    Here's one way:

    WITH the replacements AS a

    (

    SELECT "AIN" AS old_str, '10' AS new_str FROM dual UNION ALL

    SELECT 'PUP', '20' FROM dual UNION ALL

    SELECT 'GRI', '30' FROM dual UNION ALL

    SELECT 'NEW', '40' DOUBLE

    )

    normalized_data AS

    (

    SELECT p_key

    LEVEL AS sort_key

    REGEXP_SUBSTR (attribut1,

    , '[^(,)]+'

    1

    LEVEL

    ) AS str

    OF xx_dbc

    -WHERE... - If you need any filtering, put it here

    CONNECT BY LEVEL<= 1="" +="" regexp_count="" (attribute1,="">

    AND PRIOR p_key = p_key

    AND PRIOR SYS_GUID () IS NOT NULL

    )

    SELECT '(' ||) LISTAGG (NVL (r.new_str, n.str)

    , ','

    ) (ORDER BY sort_key) group

    || ')' AS new_attribute1

    n.p_key - if wanted

    OF normalized_data n

    LEFT OUTER JOIN replacements r ON r.old_str = n.str

    GROUP BY n.p_key

    ORDER BY n.p_key

    ;

    Like everything else, it depends on your version of Oracle.

    In the above query, p_key can be any unique key of xx_dbc, including attribute1 or ROWID.

    Relational databases, such as Oracle, work best when each column of each row contains 1 single piece of information, not a list delimited a number of parts.  It is so fundamental to the design of the table what he called the first normal form.  Most of the work to this problem is to convert your data denormalized in first normal form, and then convert back again.  This problem, like many others, would be much simpler and more effective if your table is in first normal form.

    The above query assumes that the replacement of the chains (for example 'AIN' and '10') are not already in a table.  If they are, or they can be derived from a table, then you need not replacements subquery; Use your actual table.

  • Forms of multi column?

    Is there a way to create a multi column form and if so, how?

    I want to create a form that has a ton of fields and want IT to a mile long, multi column would be very useful.

    Thank you!

    Simply drag each of the form fields you want.

  • Is there a way to get a list of tables with multi-column primary keys?

    I have a model over 1000 tables, each containing primary and some keys with unique indexes.  I need a list of multi-column primary keys and a list of the unique indexes that are not the primary key.  Is there a way this information easily?

    I have a generator that creates the merge instructions and I needed a way to retrieve the PK, if any, UK and otherwise the first Unique Index.  This comes from a cursor, so there are some variables for the schema and the name of the table and a constant for pk 'P' and 'U '.

    -- Primary/Unique Key
    SELECT   *
    FROM     dba_cons_columns concol, dba_constraints con
    WHERE    concol.owner = UPPER ( pv_schema )
    AND      concol.table_name = UPPER ( pv_table_name )
    AND      ( con.constraint_type = const.v_constraint_primary
    OR        ( con.constraint_type = const.v_constraint_unique
    AND        NOT EXISTS
                 (SELECT NULL
                  FROM   dba_constraints conx
                  WHERE  conx.constraint_type = const.v_constraint_primary
                  AND    conx.owner = con.owner
                  AND    conx.table_name = con.table_name
                  AND    conx.constraint_name = con.constraint_name) ) )
    AND      concol.owner = con.owner
    AND      concol.table_name = con.table_name
    AND      concol.constraint_name = con.constraint_name;
    
    -- Unique Index
    SELECT *
    FROM   dba_ind_columns indcol,
           (SELECT   indcol.table_owner,
                     indcol.table_name,
                     indcol.index_owner,
                     MIN ( indcol.index_name ) min_index_name
            FROM     dba_ind_columns indcol, dba_indexes ind
            WHERE    ind.index_type = 'NORMAL'
            AND      ind.uniqueness = 'UNIQUE'
            AND      indcol.table_owner = UPPER ( pv_schema )
            AND      indcol.table_name = UPPER ( pv_table_name )
            AND      indcol.table_owner = ind.table_owner
            AND      indcol.table_name = ind.table_name
            AND      indcol.index_owner = ind.owner
            AND      indcol.index_owner = indcol.table_owner
            AND      indcol.index_name = ind.index_name
            GROUP BY indcol.table_owner,
                     indcol.table_name,
                     indcol.index_owner) ind
    WHERE  indcol.table_owner = ind.table_owner
    AND    indcol.table_name = ind.table_name
    AND    indcol.index_owner = ind.index_owner
    AND    indcol.index_name = ind.min_index_name;
    

Maybe you are looking for

  • When I create a link in WordPress it will not open the link in a new window

    HelloI've been creating websites in WordPress for a few years and still today, I find that when I create a link to open it in a new window using Firefox as browser the link just opens again the same page This is the code: -."< a title ="learn more"hr

  • To do AMD265X GPU instead internal Intel HD GPU

    .. .but I do not use a game - just Photoshop! The Intel Integrated graphics work well with my configuration of Photoshop, plugins keep crashing. I want to see what happens when I use the AMD GPU?

  • Qosmio F60-111 - HDD is dead

    I have a Qosmio F60-111 6 months ago and I have a problem with the hard drive.The computer expert my computer has a sensitive hard drive, even just a low vibration can destroy or damage my hard drive. My hard drive is now damage because of this sensi

  • BlackBerry Smartphones Blackberry Bold 9650 problems! Help, please

    I down grade my phone, but a part of the rim is missing and now I can't put to level or reloading without os

  • Language change 8 Windows

    So, my laptop was having once belonged to my grandparents and it's in Chinese, so now that I confess, I changed to English, but a few of the tiles to start (or whatever you call them) are always in Chinese for example, maps, weather, music. Also when