simple way to merge two rows in a

11g 11.2.03
with test_temp as 
 (select 'x' key,to_char(1) col1,null col2 from dual
  UNION
  select 'x' key,null col1,'a' col2 from dual
  UNION
  select 'y' key,'a' col1,'b' col2 from dual
  UNION
  select 'z' key,'a' col1,null col2 from dual
  UNION
  select 'z' key,null col1,to_char(2) col2 from dual)
select * from test_temp
gives
KEY    COL1      COL2 
----- -------  -------  
x        1
x                  a
y        a         b
z        a       
z                  2
smart way to get:
KEY    COL1      COL2 
----- -------  -------  
x        1        a
y        a        b
z        a        2
Essentially, I want to merge two lines based on a common key and remove all columns with NULL values, and merge them into a single line. The col1 and col2 can have any data types (number, char, date, etc.) ideas?

Published by: user13007502 on July 13, 2012 01:11

Published by: user13007502 on July 13, 2012 01:46

Published by: user13007502 on July 13, 2012 02:05

Published by: user13007502 on July 13, 2012 02:09

user13007502 wrote:
Sorry guys. My example was not the best. The numbers are just one example. I expanded the sample to display more realistic data.

I just want to know if there is a smart way to merge two or more lines according to a key. Line is merged only when the merged line will result in a single line.

So, as I said...

SQL> ed
Wrote file afiedt.buf

  1  with test_temp as
  2   (select 'x' key,to_char(1) col1,null col2 from dual
  3    UNION
  4    select 'x' key,null col1,'a' col2 from dual
  5    UNION
  6    select 'y' key,'a' col1,'b' col2 from dual
  7    UNION
  8    select 'z' key,'a' col1,null col2 from dual
  9    UNION
 10    select 'z' key,null col1,to_char(2) col2 from dual)
 11  select key
 12        ,max(col1) as col1
 13        ,max(col2) as col2
 14  from test_temp
 15* group by key
SQL> /

K C C
- - -
z a 2
x 1 a
y a b

What is the problem you are having?

I feel that you don't even try the solutions proposed. Or well you're not giving us a pretty good example of what is the question.

Tags: Database

Similar Questions

  • Easy way to merge two iTunes libraries?

    Hi, I would like to see if I can get help with iTunes

    We had an iTunes library on a home computer and my ex-wife made Jazz playlist to play at parties, etc..

    I would like to copy the playlist to my iTunes library on my new computer.  Unfortunately, it takes about 4 hours, so I can't burn it to a single disc.  I guess I could burn to multiples, but I wanted to see if anyone has a recommendation on an easier way to do it.

    As a follow-up there may be other songs in the old library that I want to copy and wanted to ask you to do this as well.  My concern is that if I copy everything that I find myself duplicates in the current library.

    Thank you very much for the help.

    Cvass,

    There is no need for burning.  Copy the audio files from the old computer to a flash drive.  Insert the drive in the new computer and then drag the files (in small quantities) in the automatically add in the iTunes folder, which is located in the iTunes Media folder.  iTunes will add to the library.

  • Is there an easy way to merge the two databases?

    I would like to know if there is an easy way to merge two data from a single database?

    The two databases are generated on different machines with different data (no duplicates).


    Thank you!



    Mark

    It is possible that the db_dump and db_load utilities can be used here.   They are documented in the BDB C API reference manual.      Basic process would be to empty the database on a system, move the files to the other system can use db_load and load it into the existing db.    Since there is no duplicate, this process should work for you.

    Thank you

    Mike

  • Duplication of any libraries - any way to merge?

    Hello

    In my 'Images' folder, I have now two libraries - iPhoto Library and photo library.  Having considered the two libraries there is a lot of overlap and duplication between them, and as they both occupy about 110 GB each I will refine them.  Y at - it a simple way to merge libraries, removing duplicate images in the process?

    Incidentally, I just opened the iPhoto library in iPhoto and recalled iPhoto how elegant has been compared to its replacement teen Photos - this is the progress apparently

    John

    You can remove whatever library is not in use (probably iPhoto) but you will not regain a lot of space. The two libraries use the same set of images, which are the bulk of the size.

  • What is the best way to run two concurrent programs using the output of either executing the other?

    I wanted to just kind of get a notice of some people here. I have two main screws the first is a data acquisition system that displays 99 different sensors and which feeds on these data in a table. The second is a real-time processing system that is designed to take the painting and do many calculations. The two output data from screw at the front that I want to see, so I don't want to use just as a Subvi.

    Is there a simple way to run two screws, using the output of the data acquisition system to power the processor so that you can easily see the signs before two screws? I had thought to simply copy the code from the processor in real-time in the DAQ VI, but I fear that the VI resulting will be very large and unsightly.

    On a side note, I'm more thinking about this? I apologize if this is a stupid question, it has been a long week... aaaand it's Wednesday.

    Look at the Architecture of producer/consumer.  It will be a good starting point, even if you find that you need to change.  When performing data acquisition and processing of tasks in parallel loops, they can both run simultaneously.  Both can feed data to the main draw of the VI.

    I'd probably use three loops with the third being the user interface only.  All that must be displayed to the user is sent to the GUI of the acquisition of data or processing loop loops and commands or entered by users are returned in these loops, probably through queues.  The wall of the VI of data acquisition and processing VI are never displayed to the user.  Especially the treatment, because it runs on a system in real-time, should avoid synchronization issues that can present a graphical interface.

    Lynn

  • Merge two favorite files - one of the former without losing new entries

    I'm trying to move the Favorites from one computer to another, without losing the favorites that have been added to the second computer, which can ONLY be the first. Once I have export favorites from the first computer on a port USB, import replace simply all the Favorites on the second computer folder or it will ask me if I want to record a new one to the old double the second favorite of the computer file (like when you save jpg files).

    Or is there another way to "merge" two folders, as visually opening upward both files and selecting what to switch to the hand...

    Thanx

    PS - am moving to Vista on a Windows 7 computer. as well as the synchronization of the two win 7 after that.

    Hi Maril,

    Thanks for posting your question in the Microsoft Community Forums.

    Based on the information, you find out when you try to move the Favorites from one computer to another, if the existing Favorites in the second computer will be deleted.

    Usually, when you import bookmarks to another computer, it will not replace the already existing bookmarks on the second computer.

    However, to be on the safer side, you can take a backup of the bookmarks on the second computer to another folder or another location.  Try favorites of the importation of the first computer to the second computer, check if you are able to access to existing favorites as well as any.

    If this is not the case, try adding the Favorites of the backup location to imported Favorites and check if it helps.

    You can also copy favorites from the second computer to the first computer and save it in a new folder. Try to create another folder containing the computer the two first and second Favorites and then import the Favorites from this folder to the second computer.

    For more information, see the article:

    Add, view, and organize Favorites

    Hope the helps of information.

    Let us know if you need help with Windows related issues. We will be happy to help you.

  • How to merge two images in 14 elements?

    I've read a few articles on different ways to merge two photos in 14 elements using Photomerge, but I don't see a Photomerge announced on my new screen 14 items.  I said to go to "improve, Photomerge, Photomerge dial", but only 'Enhance' watch.  Then I read to go to "Editor, guided edits" or in the Organizer, go to "Edit, Photomerge."  I can't find anything that says Photomerge.  Help, please! -Thank you very much, Anna

    annam61239719 wrote:

    I've read a few articles on different ways to merge two photos in 14 elements using Photomerge, but I don't see a Photomerge announced on my new screen 14 items.  I said to go to "improve, Photomerge, Photomerge dial", but only 'Enhance' watch.  Then I read to go to "Editor, guided edits" or in the Organizer, go to "Edit, Photomerge."  I can't find anything that says Photomerge.  Help, please! -Thank you very much, Anna

    The Photomerge function was moved to 'Expert' display mode to the mode "guided edit.

    What has not changed is that you can always select your files in the organizer and use the Edit menu > Photomerge.

  • 2 my documents folders. Two different computers. Way to merge?

    I have two computers linked together. There are two "My documents" folders (one for each computer). I want to merge two files into one, so that there is a standard folder for documents. Is there an easy way to do this?

    You cannot delete my documents on a computer, but you can certainly keep them empty.

    If a method is to download and store all your documents in a centralized like microsoft skydrive site location.  However, both computers must have access to the internet to access your reader account free sky...

    Another method is to get an external hard drive and keep a set of documents on it.  can only carry a single external hard drive between computers.

    There is also an option / workaround, you can implement.  keep both my documents folder, but use microsoft sync toy to keep them synchronized so that they will update the same files...

  • Is there a simple way to reduce/increase the two A / track V sizes in the CC timeline? [was: Adobe CC]

    Y at - it a simple way to reduce / increase the two A / track V sizes in scenario C C?

    There are keyboard shortcuts for expand/collapse the heights of the audio track and shortcuts to expand/collapse the heights of video tracks, but not both at the same time in increments (although you can quickly develop their all at the same time).

    If you are using Premiere Pro default keyboard:

    Opt + - / = collapses / develops audio tracks

    Cmnd + - / = collapses / expands the video tracks

    Shift += develops all the video AND audio tracks

    Shift + - collapses all the video AND audio tracks

  • Concatenate two rows

    Hello

    I have a requirement where to check a table with a list of values in reference data.

    I get two rows with a column for each output that every time and I need to concatenate the two rows in a field.

    Is there any combination/processor that can be used to do this?

    I tried concatenate / merge and merge data from processors without success.

    Any direction is much appreciated.

    Thank you

    SID

    It is not clear what criteria do you use to determine which records to eat together. The research is not relevant?

    If it's all the records that spent searching you need to eat, it's simple, you can just add a grouping key (for example to add string to a value of 1 attribute), and then group and merge, creating a merged with output value ' delimited list by a "which is used to create the string.

  • Merge two e-mail accounts

    I have a few email addresses Yahoo and SBC Global, I'm able to check in a single mailbox on yahoo.com, while being able to select in each address when you compose an email.

    However, I'm unable to understand how to configure my Apple Mail account to reflect my yahoo.com account. Currently in Apple Mail, I have a separate account of the SBC Global and a separate account of Yahoo. I implemented this way because it was the only way I knew to be able to select different e-mail addresses when you are composing an email. The problem with this configuration is the number of unread emails is doubled due to them being two identical mailboxes.

    If possible, I would like to combine/merge the mailboxes while being able to have two e-mail addresses to select when you compose an email.

    I hope that what I am asking is logical and someone out there will be a solution because I know that I'm not the only person using several e-mail on the same Yahoo account alias.

    Thank you, in advance, for any help you are able to provide.

    Chris

    Hello and welcome to Apple support communities, OMMBoy.

    If I understand your post right, you are wanting to be able to set up your Yahoo/SBC Global account once in post, rather than implement them separately, but still be able to choose one or the other when you dial an outgoing message. I know from personal experience, how practical is to be able to choose the account that come from your emails, so I'm happy to help you find a solution for this today!

    It is not a way to 'merge' mail accounts in the mail that you mentioned, but hopefully that won't matter because it seems that these two accounts are already merged on the side server. That you would do so first remove one of these mail e-mail accounts so that only rest. It shouldn't make a difference, that you decide to keep. You can find steps on how to remove one of these email accounts in Mail for Mac: Configure Mail with your email accounts, specifically this section:

    Delete an account

    When you delete a mail e-mail account, messages from the account are deleted and are no longer available on your Mac. The copies of the messages remain on the mail server account and are still available (from webmail, for example).

    Important: If you are not sure if you want to keep the messages are still on the mail server, move or copy them to a mailbox stored on your Mac (the mailbox appears in the section on my Mac in the mail sidebar) before deleting the account in Mail.

    1. Choose Mail > Preferences, and click accounts.

    2. Select an account, then click on the button Delete .

      Note: If the account is used by other applications on your Mac, you are prompted to delete the account in Internet accounts system preferences. Click the button to open an Internet account, and then clear the box e-mail for the account. To stop using the account in all applications, make sure that the account is selected, and then click the button Delete .

    Once you have one of these e-mail accounts deleted, you will follow the steps of Mail (Yosemite): use e-mail alias, to add the address to remove as an alias. Don't worry that the article shows "Yosemite", the steps are the same for Sierra.

    Thank you for using communities of Apple Support.

    Take care.

  • How to merge two partitions in XP

    I have Windows XP Service Pack 3.

    The space becomes very low on my NTFS Partition that contains Windows XP. There are partition with more than 100 GB of free space I want to access — preferably by merging two partitions or not not to resize the NTFS partition.
    From Googling, it seems that I cannot use the native Windows XP and need a third party application software, but I see that's not without risk of data loss.
    Can someone advise please?  Ty.

    6. as a result, select your C: drive and the option "Extend Volume". Your computer will automatically select the empty spaces available on your hard drive and you can change them if you want to do.

    This desire. Not. Work. for system volumes or boot or a partition on which the pagefile system is located.

    In addition, the GUI (using the disk management) method only works with volumes 'simple' or 'split', which are forms of "Dynamics" volumes and volumes of"base" that most of the people have set up.  http://support.Microsoft.com/kb/314343

    Given that the OP asked about the increase in the size of the partition system (my Partition NTFS which contains Windows XP) which is probably also the boot partition as where the pagefile, the posting is irrelevant.

    For Andrew pieces:

    Here are a few options in alphabetical order:

    Acronis Disk Director
    EASEUS Partition Manager free
    O & O Partition Manager 3

    Paragon Partition Manager

  • merging two partitions xp services Pack 3

    in microsoft site I am serching thi one give to it

    Merge a Partition in Windows

    • 1

      Click on the button of the menu 'start '.

    • 2

      Click on "Control Panel."

    • 3

      Click on "Administrative Tools".

    • 4

      Double-click 'Computer management'. If you are prompted to enter the administrator password, type it and press 'Enter' on your keyboard.

    • 5

      Choose "Disk management" option under the 'Storage' to display the list of all partitions on your disk or hard drives.

    • 6

      Right click on the partition that you want to merge with your primary hard drive.

    • 7

      Click on 'Delete Volume... "in the choice of menu.

    • 8

      Click the drive you want to partition space to merge with.

    • 9

      Click "Extend Volume... "Your computer automatically assigns all extra space to this player

      in the light of the foregoing, all are made, but I use xp ser pack 3 in there there is no opection of Volume to expand. How to merge two partitions in xp pack 3 ser

    Hello

    I don't know any way in XP except by specialist partition management software. I use Acronis Disk Director, but it costs! There may be some freebies autour but none I have meet in so I wouldn't comment on their reliability and efficiency, or even their ability to do what you want.

    If you're lucky, someone else can come back to this thread and give details of a free alternative.

    Tricky

  • HP Laserjet P1102: Two rows of black dots on every print

    I recently removed the seals and tested a few impressions, but each of them contains two rows of black dots on the left side (a line more fat and other points more small rank). I did the cleaning print but no use. Here are some pictures of the question. I can print any document, but the points are the problem. I run on the genuine laser HP cartridge by default. Also, the points are spaced the same way.  Any help would be appreciated...

    No! The load inside the cartridge is bad

  • Is it possible to join/merge two conference calls in MCU for one call in the same MCU

    Situation - endpoint is part of two meetings of MCU (with one call on hold).  I want to merge these two meetings to the MCU.  Is there a way.  MCU is 45xx series and this is a deployment of VCS - MCU.  Thanks in advance.

    No way to merge that I know, I've had similar scenarios and there is no automatic way to do it, the Conference, the participants will have to unplug one and join the other.  Multiway will not work because that is intended to the unique endpoints being transmitted to a MCU, no MCU is not lift themselves.

Maybe you are looking for