remove columns from duplicay

I have the following table
create the table cust_phone
(
number of cust_id,
telephone1 varchar2 (20).
Telephone2 varchar2 (20).
phone3 varchar2 (20).
phone4 varchar2 (20).
phone5 varchar2 (20).
phone6 varchar2 (20).
phone7 varchar2 (20).
phone8 varchar2 (20)
)

My current data are like:

Select * from cust_phone where cust_id = 1
1 2784819 2784818 2784816 2784819 2784818 2784819 2784815 2784816

I want an update query nullfy columns that are double with others in the same row, only one should exist.

Try this...

UPDATE cust_phone a SET (phone1,phone2,phone3,phone4,phone5,phone6,phone7,phone8) =
     (
          SELECT  phone1,phone2,phone3,phone4,phone5,phone6,phone7,phone8 FROM
               (
               SELECT cust_id,
                    MAX(DECODE(ph,'PHONE1',phone_nos)) PHONE1,
                    MAX(DECODE(ph,'PHONE2',phone_nos)) PHONE2,
                    MAX(DECODE(ph,'PHONE3',phone_nos)) PHONE3,
                    MAX(DECODE(ph,'PHONE4',phone_nos)) PHONE4,
                    MAX(DECODE(ph,'PHONE5',phone_nos)) PHONE5,
                    MAX(DECODE(ph,'PHONE6',phone_nos)) PHONE6,
                    MAX(DECODE(ph,'PHONE7',phone_nos)) PHONE7,
                    MAX(DECODE(ph,'PHONE8',phone_nos)) PHONE8
                    FROM (
                         select cust_id,ph,nullif(phone_nos,lag(phone_nos,1,0) over (partition by cust_id order by cust_id,phone_nos,ph)) phone_nos from
                              (
                              select cust_id,'PHONE'||lvl ph,
                                   decode(lvl,1,phone1,2,phone2,3,phone3,4,phone4,5,phone5,6,phone6,7,phone7,8,phone8) phone_nos
                              from
                              cust_phone,(SELECT LEVEL lvl FROM dual CONNECT BY level<=8) lvl_tbl
                              ORDER BY 1,2
                              )
                              order by cust_id,phone_nos,ph
                         )
                    GROUP BY cust_id
               )
          WHERE cust_id=a.cust_id
     )

Tags: Database

Similar Questions

  • How to remove columns from table form of process

    Hello

    I have a form of process UD_FN_USR. I have created a userid long type column and later the requirement has changed and I need to change the type of chain. I am able to remove the column from console design but in the table, the left column while I coulnt create the column with the same name as the type string, its tellling leaves the same name of column with a different data type in the current version or earlier versions.can someone please tell me how do to solve this problem

    You need to remove since the end of the database as suggested Sunny.

    ALTER TABLE DROP COLUMN UD_ABCD_UID UD_ABCD

  • How to remove columns from the table on the master 1-0?

    I have an array of 96 columns with strings. I also have the array of int 96-elemets (mask) with 1 and 0.

    What I want to do is to is to remove (or hide - but I read that it is not possible) all the columns with index corresponding to 0 in the mask table.

    example:

    columns in the table

    1 2 3 4 5

    mask

    0 1 0 0 1

    I want to remove the columns 1, 3 and 4 and leave only 2 and 5 in my table.

    How can I do?

    If I create loop for with i as the index of the column, when I do DeleteTableColumns() columns number decreases, and I get an error of range out of

    Or do I have an option to hide the unnecessary columns (not set their width to 1, it's very ugly-looking)?

    Please help me (())

    Hello rovnyart!

    1. removal of columns in the table:

    I suspect that the reason why you get the out-of-range error is due to fact that in your loop, you delete the columns in the table, you'll eventually end up by referring to a column that no longer exists, because the other columns before it have been deleted. While you remove each column of your table in the loop for example, the column index number will move, because you deleted the other columns in front of her.

    To resolve this, even if you delete a column in your loop, make sure that you take also into account that the index of the column is moved because of the removed columns.

    2 hide columns in table:

    You can use the ATTR_COLUMN_VISIBLE attribute to hide columns in the table:

    http://forums.NI.com/T5/LabWindows-CVI-idea-exchange/add-attr-column-visible-attribute-for-table-Col...

    http://zone.NI.com/reference/en-XX/help/370051Y-01/CVI/uiref/cviattrcolumnvisible_column/

    3 alternatives:

    Note that another alternative would also use a tree instead, control as the tree control also supports the hidable columns:

    http://forums.NI.com/T5/LabWindows-CVI/table-hide-column/TD-p/569773

    Best regards!

    -Johannes

  • How to remove a column from a table in a dell identtiymananger 7.0

    How to remove a column from a table in a dell identtiymananger 7.0

    Hello

    In Version 7 of the removal of a single custom column can be accomplished by a stored procedure, available in the database called: QBM_PColumnDrop

    Hope that helps.

    Cordially Fatih

  • Remove the column from the compressed tables

    NLSRTL11.2.0.3.0Production
    Oracle Database 11g Enterprise Edition11.2.0.3.064 bit Production
    PL/SQL11.2.0.3.0Production
    AMT for Linux:11.2.0.3.0Production

    Hello

    I read on how to do to remove a compressed table column - first set unused and then drop unused columns. However, in the example below on the basis of data, I ran it, it does not work. Please, can you tell me WHEN this approach does not work. What is dependent on - settings or something else. Why can't I drop unused columns?

    And the example and errors:

    create table tcompressed compress in select * from all_users;

    > TCOMPRESSED table created.

    ALTER table tcompressed add x number;

    > table TCOMPRESSED altered.

    ALTER table tcompressed drop the x column;

    >

    Error report:

    SQL error: ORA-39726: unsupported operation column add/drag on compressed tables

    39726 00000 - "operation column add/drop not supported on compressed tables. ''

    * Cause: Not support add/column operation move compressed tables

    elapse.

    * Action: When adding a column, do not specify a default value.

    DELETE column is only supported in a column SET UNUSED

    (remove the column metadata).

    ALTER table tcompressed unused column of the set x;

    > table TCOMPRESSED altered.

    ALTER table tcompressed drop unused columns;

    >

    Error report:

    SQL error: ORA-39726: unsupported operation column add/drag on compressed tables

    39726 00000 - "operation column add/drop not supported on compressed tables. ''

    * Cause: Not support add/column operation move compressed tables

    elapse.

    * Action: When adding a column, do not specify a default value.

    DELETE column is only supported in a column SET UNUSED

    (remove the column metadata).

    As you can see even after changing the table defining the column as unused X I still can't drop by DROP UNUSED COLUMNS.

    Thank you.

    If you enable compression for all operations on a table, you can delete the columns in the table. If you enable compression for the only direct-path inserts, you can't remove columns.

  • Remove the column from the table compress

    I try drop column from table DPRUEBA, with compression option:
    SQL>select * from v$version
      2  /
    
    BANNER                                                                
    ----------------------------------------------------------------      
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi      
    PL/SQL Release 10.2.0.4.0 - Production                                
    CORE     10.2.0.4.0     Production                                            
    TNS for Linux: Version 10.2.0.4.0 - Production                        
    NLSRTL Version 10.2.0.4.0 - Production                                
    
    5 filas seleccionadas.
    
    Transcurrido: 00:00:00.09
    SQL>
    SQL>CREATE TABLE DPRUEBA
      2    (COL1 NUMBER,
      3    COL2 NUMBER) COMPRESS
      4  /
    
    Tabla creada.
    
    Transcurrido: 00:00:00.06
    SQL>
    SQL>ALTER TABLE DPRUEBA DROP COLUMN COL2
      2  /
    ALTER TABLE DPRUEBA DROP COLUMN COL2
    *
    ERROR en línea 1:
    ORA-39726: operación de agregación/borrado de columnas no soportada 
    en tablas comprimidas 
    
    
    Transcurrido: 00:00:00.06
    Any idea?

    You can always do something like this

    SQL> CREATE TABLE DPRUEBA
      2   (COL1 NUMBER,
      3    COL2 NUMBER) COMPRESS
      4  / 
    
    Table created.
    
    SQL>
    SQL> ALTER TABLE DPRUEBA DROP COLUMN COL2
      2  /
    ALTER TABLE DPRUEBA DROP COLUMN COL2
                                    *
    ERROR at line 1:
    ORA-12996: cannot drop system-generated virtual column
    
    SQL>
    SQL> create table new_DPRUEBA
      2  as
      3  select col1
      4    from DPRUEBA
      5  /
    
    Table created.
    
    SQL>
    SQL> drop table DPRUEBA
      2  /
    
    Table dropped.
    
    SQL>
    SQL> rename new_DPRUEBA to DPRUEBA
      2  /
    
    Table renamed.
    
    SQL>
    SQL> desc DPRUEBA
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------
     COL1                                               NUMBER
    
    SQL>
    SQL>
    SQL> drop table DPRUEBA
      2  /
    
    Table dropped.
    
    SQL>
    SQL> 
    

    Note: you must take care of the constraints and triggers, and others

  • How to remove programs from the system tray without removing them from the startup?

    How to remove programs from the system tray without removing them from the startup on Windows XP folder?

    Hello

    The first step is to identify the program that represents the icon and decide whether it should be in the system tray (most are not necessary). Hold the cursor of the mouse on the icon to see the name of the program that launches the icon.

    The best bet is to click the icon to see if this opens the box of the program options. If so, look for a selection similar to "remove from the system tray.

    Alternatively, you can hide the icons in the system tray.

    Here's how:

    1. right click on the taskbar and select "Properties".

    2. in the "Notification area" click "Hide inactive icons" if she already unchecked and then click on the button "Customize".

    3. click on the ' column next to each of your current behavior and choose one of the three behaviors for each program icon that appears in the system tray: "Hide when it is idle," "Always hide", or "always show".ยป

    If you hide an icon, but then see it again the next time that you log on to Windows, you may need to uninstall the program to permanently remove the icon. Uninstall the program permanently removes the program from your computer. For more information, see Uninstall or change a program.

  • Question: Remove spaces from |

    I have a table that has a column named NAME and under it contrain a list of names.
    NAME
    Ann Pert
    Steven Pappas
    Mai Xiong
    I'm trying to join this table to the other which contrain one list of names as well, but they are in the format of the first NAME and last NAME in separate columns
    FIRST NAME     LAST NAME
    ANN               PERT
    STEVEN              PAPPAS
    I'm trying to do something like:

    Select *.
    TABLE_NAME FROM HAS, TABLE_NAME B
    WHERE B.SID = B.FIRST_NAME | B.LAST NAME

    But because there is a space between the first and the last name in the table A is not picking up. So is there a way to remove spaces from | or another method

    (I have not uplad a DataSet because it's just an issue that seems easy to answer)
    Using oracle 10

    Why not just concatenate fisrt name + space + family name:

    Select *
    FROM TABLE_NAME A, TABLE_NAME B
    WHERE A.NAME = B.FIRST_NAME || ' ' || B.LAST NAME
    /
    

    SY.

  • How to remove photos from my iphone6s after their importation?

    How to remove photos from my iphone6s after their importation?

    Hello KConstant,

    I understand that you're looking to remove photos from your iPhone, after you import the to your Mac. It depends largely on how the images are imported into your Mac.

    If you use iCloud photo library, remove photos from your iPhone, after they have synched to the Photos on your Mac afterwards would remove these photos on your Mac as well, like iCloud photo library is designed to synchronize your iPhone with iCloud and Mac.

    However, if you are importing photos via the USB port of the Photos app, you should be prompted to delete pictures from your device once the import is complete:

    Once the import is complete, a message asks if you want to delete or keep the photos on your device. Click on remove items to remove photos or click on keep items to keep them on the device.

    Import photos and videos from your iPhone, iPad or iPod touch
    https://support.Apple.com/en-us/HT201302

    You can also (it not allowed you iCloud photo library on your iPhone), you can use the image capture on your Mac app to delete images from your iPhone. This can also be useful to remove the last images that have already been imported into the Photos on your Mac. Once you have selected the images you want in the Image Capture, you can click on the prohibitive red symbol () to delete the selected items.

    Image capture: transfer images and other elements of your device
    https://support.Apple.com/kb/PH17894

    Concerning

  • How can I remove photos from my iPad without deleting them from my iPhone

    Can I remove photos from my iPad without deleting them from my iPhone?

    Can I remove photos from my iPad without deleting them from my iPhone?

    Depends on how you put Photos in place, and where is that you remove them.

    You have iCloud as library lit? If you do, then the answer is no.

    If you do not have library on iCloud and if you try to delete your photo stream, then no..

    If you try to remove the film, then Yes, you can do it.

    See you soon,.

    GB

  • How to remove Photos from the iPhone/iPad/iCloud and no pictures

    How to take a photo with my iPhone/iPad, allow it to synchronize with Photos on my Mac via iCoud, then delete from my iPhone/iPad/iCloud and removes any Photos on Mac? I want to save the photo on your computer and save space on small devices?

    I keep seeing articles on the iCloud market turn but it seems the photos all return on the devices once restarted. I want to iCloud on use as a conduit to get the photos to my computer, not as a large storage space. I want the Photos app on my Mac where all the photos are filled and stored and choose those which is left each device.

    Right now they are all in the pictures on the Mac, but I'm worried if I remove it from my iPhone/iPad that they will disappear from Photos on the Mac. I don't understand the new Photos app with all the missing features of iPhoto.

    Thank you!

    You can not that's not how works iCloud photo library - it is not a conduit but a total synchronization service whose entire raison d'etre is to keep libraries connected identical - all changes made on any device (addition, deletion or modification) are made on all devices. For devices with limited memory, using optimized photos

    If this isn't what you want then use another service - USB import, iTunes sync, MyPhotoStream for example each do different things and everyone can move photos from one device to another

    And Photos lack a lot of features iPhoto form - in fact much more features than iPhoto including iCloud library there like a bigger and better editing capability and better external editing capability and so on

    LN

  • How to remove photos from a photo stream on the iPhone, but keep them on Mac?

    Hello world

    I tried to find the answer to my question in the FAQ, but so far I've failed. I'd be really grateful if someone could help me.

    I have an iPhone (5s) and a MacBook Air (13 inch, early 2015). I have not activated the iCloud photo library, but I use the photo gallery on both devices. Because I often take pictures with my phone, I'm running out of memory space on my phone.

    In regards to this and photo stream feature, I have several questions:

    1. If I want to make more room on my iPhone, I have to delete some pictures. Assuming that I do this, these pictures are deleted from my Mac after 30 days?

    2. How can I remove photos from my iPhone without deleting them from my Mac (because I turned on the feature of photo stream)?

    3. If I import the photos from my iPhone in the Photos App on my Mac (when it is connected to my Mac with a USB cable), they are 'safe '?

    I hope that my questions are understandable and I would appreciate all the help I can get.

    Thanks to all and best wishes,

    Lars

    1. no - as long as you have allowed MyPhotoStream to import photos - if they have not been imported yet then they will be gone

    2. after importation of pictures you can delete them from the iPhone, and they will remain in Photos of the moments / pictures

    3 - Yes - but if you import several times, you will have duplicates - you should use USB or PHM import

    LN

  • I downloaded an application from my iphone and then deleted. Now when I open AppStore I purchased apps and its still there. How can I remove it from there though even I have no more app?

    I downloaded an application from my iphone and then deleted. Now when I open AppStore I purchased apps and its still there. How can I remove it from there even if I have no more app?

    The applications that you have downloaded will be available for re - download also a practice.

    Apps y cannot be removed, you can hide only.

    Read here: hide and expose the purchases made on the iBooks Store - Apple Support, App Store or iTunes Store

  • How to transfer photos from my iPhone to my iPad, put them in albums and then remove them from my iPhone

    How to transfer photos from my iPhone to my iPad, put them in albums and then remove them from my iPhone

    There are several methods.

    You could make a start by looking at this article.

  • How to remove photos from my computer to my Iphone 6.

    Hello I have imported digital SLR photos to my computer then to my iPhone 6, photos are able to be consulted, but the delete option is not there.

    I connected my phone to my pc to try and remove them through the MY COMPUTER tab, but the only pictures that appear are those who is on my CAMERA ROLL.

    I have a 64 GB 6 iPhone and photos take up more space. Any help would be amazing.

    Hi mulatto5o,

    I understand that you have synchronized the photos on your iPhone, and now you want to remove them. I know it's important to have control over your data, so I'm happy to provide advice to help with this.

    When the photos are synced from your computer to your iPhone, you must use iTunes to delete again. To do this, follow the same steps you did to synchronize, but uncheck the option Synchronize the Photos :

    12 iTunes for Windows: Add photos to iPod, iPhone or iPad

    Remove photos from your iPhone

    1. Connect your device to your computer.

    2. Click on the button of the device, and then click pictures.

    3. Uncheck "synchronize photos from".

    4. Click on apply

    If these photos are no longer on your computer, or if these steps do not work for you, try the steps here:

    Delete pictures and videos synced from iTunes when you can not access the originals - Apple Support

    To remove synced photos from a computer which is accessible:

    1. Create a folder on the computer that you now synchronize with and add a single photo in this folder.
    2. On the Photos tab in iTunes, click on the box next to "Sync Photos since.
    3. In the dropdown next to "Sync Photos From" menu, choose the folder that you created in step 1.
    4. Apply the change.
    5. Uncheck "synchronize Photos from".
    6. Reapply the change.
    7. Sync photos are removed from the device.

    Thank you for using communities of Apple Support, cheers!

Maybe you are looking for