Merge two records which has the same ID

Hi all

Oracle version-> database Oracle 10 g Enterprise Edition Release 10.2.0.4.0 - 64 bit
 Table DB_TEMP

create table DB_TEMP 
( Db_ID NUMBER, LAST_NAME VARCHAR2(30), 
FIRST_NAME VARCHAR2(30), MIDDLE_NAME VARCHAR2(30), M_CODE VARCHAR2(10),
PREFIX VARCHAR2(30), TITLE VARCHAR2(100),CREATION_DATE DATE); 


INSERT INTO DB_TEMP values (3, 'JOHN', 'KER', '', 'A146', '', 'PRESIDENT', '5/1/2011');
INSERT INTO DB_TEMP values (3, 'JOHN', 'KER', '', '', 'MR', 'PRESIDENT ACTIVE HERE', '5/10/2011');
INSERT INTO DB_TEMP values (11, 'MATT', 'CARLONE', '', '', 'MR', 'CHAIRMAN', '5/1/2011');
INSERT INTO DB_TEMP values (11, 'MATT', 'CARLONE', '', 'A149', '', 'CHAIRMAN INACTIVE', '5/10/2011');
INSERT INTO DB_TEMP values (40, 'JOHN', 'SMITH', 'K', 'A147', '', 'PRESIDENT', '5/1/2011');
INSERT INTO DB_TEMP values (40, 'JOHN', 'SMITH', 'K', 'A147', 'MR', '', '5/10/2011');

Required Output

DB_ID   LAST_NAME   FIRST_NAME   MIDDLE_NAME     M_CODE      PREFIX                  TITLE                CREATION_DATE
---------------------------------------------------------------------------------------------------------------------------------------------
3       JOHN             KER                      A146         MR             PRESIDENT ACTIVE HERE           5/10/2011   
11       MATT          CARLONE                     A149        MR             CHAIRMAN INACTIVE               5/10/2011   
40       JOHN             SMITH           K         A147      MR             PRESIDENT                         5/10/2011   
 
Has obtained two records with DB_ID even on different creation_dates, but some columns are filled in on the next day with the updated data. Now I need merge them into one by taking the MAXIMUM of the column

Help, please

Thank you

Published by: 960736 on November 9, 2012 10:12

Published by: 960736 on November 9, 2012 10:27

Published by: 960736 on November 9, 2012 10:48

Hello

960736 wrote:
I need complete records for title CONCATENATE them with ';' in the meantime, but title that has the M_CODE should must be first if not in does not matter in any order. Any remaining can be Max.

DB_ID   LAST_NAME   FIRST_NAME   MIDDLE_NAME     M_CODE      PREFIX                  TITLE                CREATION_DATE
---------------------------------------------------------------------------------------------------------------------------------------------
3       JOHN             KER                      A146         MR             PRESIDENT ACTIVE HERE;Member          5/10/2011
11       MATT          CARLONE                     A149        MR             CHAIRMAN INACTIVE               5/10/2011

So, for db_id = 3, wouldn't you ' PRESIDENT; PRESIDENT ACTIVE HERE; MEMBER "?"
For db_id = 11, wouldn't you ' PRESIDENT; INACTIVE PRESIDENT '?

Whatever it is, you need the string aggregation . See this page from the Oracle Base for several ways to do so. Since you have Oracle 10 and because the order is not important, I recommend so the aggregate function defined by the user, called STRING_AGG on that page, but the STRAGG called by most of the people who actually use it. Once you have created the STRAGG, you can use it like this:

SELECT       db_id
,       MAX (last_name)     AS last_name
,       MAX (first_name)     AS first_name
,       MAX (middle_name)     AS middle_name
,       MAX (m_code)          AS m_code
,       MAX (prefix)          AS prefix
,       STRAGG (title)          -- or STRAGG (DISTINCT title)
                       AS title
,       MAX (creation_date)     AS creation_date
FROM       db_temp
GROUP BY  db_id
;

Tags: Database

Similar Questions

  • Data store 'datastore1' is in conflict with a store of data that exists in the data center which has the same URL (.), but is back different physical storage

    Hello

    I am new to vCenter Server, so you can assume that I'm missing something obvious.

    I installed vCenter Server 5.5 and one of the two hosts of re-usable ESXi 5.0.0 connected correctly. When I try to connect to the second 5.0.0 ESXi host, I get the error message:

    Data store 'datastore1' is in conflict with a store of data that exists in the data center which has the same URL (.), but is supported by different physical storage

    I Googled it and found what I think are the best answers that are successful, but they all seem pretty unique in their situation (they have a cluster, I do not have) etc. Some solutions involve disconnecting the store of data and reconstruction of things. I would not make things worse and can live without doubt with the help of vSphere client (and not the web client) until maybe I can start again with a 5.5 installation to a new host once I have back up everything from the host unconnectable. I closed all the VM on the host of the second. I have put in maintenance mode. I've renamed the data store, all to nothing does not.

    Thanks in advance

    The problem is that a whole army could not be connected to vCenter due to the problem, the solution involving disconnection of the host apply.

    Here is how I solved the problem:

    1 use the client vSphere client heavy, connect you to the host that cannot not be connected to vCenter Server.

    2. click on the host computer, and then click the Configuration tab.

    3. click on "storage".

    4. find the offending on the right data store.

    5. right click on the data store incriminated and click 'remove '.

    6. click on 'Add storage' in the top right.

    7. follow the steps to find this data not mounted store. I gave him a new name just to be sure, even if it's probably not necessary.

  • Illustrator 282C pantone color numbers different for example RBG, CMYK, Web color compared indesign colors and photoshops which has the same values of color for the two C. 282 I typed in a different color and the same issue. Why would it be different in a

    This is illustrator

    It's photoshop

    Libraries are the same? The two RGB colors are different and they have different look on the screen.

    None of this has to do if you are not working with color management and conversion of spot color to a CMYK process color, which seems to be the case here...

    Mylenium

  • two nodes ASM has the same instance name

    Hello

    I created a grid of ASM of two nodes, when the grid facility (11.2.0.1) finish he created the + ASM1 as instance name for my two knots.

    I have install the ORACLE_SID in + ASM1 and + ASM2 node1 and node2, respectively prior to installation.

    What is wrong, I do it for the installation of the grid? Please suggest.

    Thank you

    To create a virtual environment of RAC in VirtualBox or to share devices in an environment of ASM, you should turn off the virtual machine and change devices in VirtualBox using the following command:

    $ VBoxManage modifyhd asmdisk1.vdi - shareable type

    Then you can add the same features and use the disgroups on different nodes of the DSO. BTW, this is rather a question of the use of VirtualBox for which there is a special forum.

  • How can awesome bar - I stop the auto switch to another window which has the same open site.

    Several times I want multiple copies of a site open, like to watch several mappings. But when I enter a new window mapquest.com , FireFox switches back me on the window that already has a copy of mapquest open. I can do things to get a 2nd copy open, but it's quite tedious. How can I disable this automatic switch for the other window? FireFox on Windows Vista Edition 12.0 Home Premium SP2

    • CTRL + left click or Middle-click the Reload button to open the current page in a new tab.
    • CTRL + left click or Middle-click points in the history of the buttons back and forward to open a page from this list in a new tab.
    • Duplicate a tab with its history by pressing CTRL and dragging the tab in a new position on the tab bar.
    • By dragging a tab in the window of the browser will detach from the tab and move in a new window, it is called tab tearing.
    • Drag a tab to the tab bar in the original or the anthers window to cancel a detachment or move a tab of a specific window. If a window is empty (you rock the last tab) then this window will be closed automatically.
    • You can use ALT + D to set the focus to the address bar and use ALT + Enter to open the current page in a new tab (no need to release the ALT key).

    Check and tell if its working.

  • Components ADF which has the same functionality as mailto tag in html

    I need an adf feature that performs the functionality of html "mailto" tag.

    Help out me.

    I used af:resource and f: verbatim

    does not

    User,

    Always mention your JDev version.

    Have you checked on af:goLink? You can set the property of the destination of it to mailto:abc@...

    Arun-

  • IMessage Apple Watch has two interviews separated with the same person?

    My new Apple Watch has a problem with iMessage and I know how to fix this on my iPhone but not watch?

    On my iPhone, that my ID apple is connected to more than 10 devices and sometimes when a new device is added, it adds the addresses on my apple for iMessage and FaceTime ID and I always fix by unchecking the addresses that I don't want in the application settings under "Messages" and "FaceTime." However, this isn't the same thing to watch because there is no option in the settings on the Apple Watch and the watch App on my iPhone.

    I would like to help please?

    Hello

    Apple Watch uses the same parameters (for how you can be reached and how new conversations are started) for Messages as your iPhone.

    If you have two interviews separated with the same person, the following steps may help:

    • On your iPhone, check if there is more than one contact form in Contacts of this person (if so, remove duplicates).
    • Delete old Messages conversations with this contact on each of your iPhone and watch:
      • iPhone: app Messages > swipe to the left on a message thread > delete.
      • View: Open the Messages app (from the home screen, which is accessible by pressing the digital Crown) > swipe to the left on a message thread > tap on Trash / delete.
    • On your iPhone in the app Watch: Watch My > general > reset > press reset sync data:
      • You won't see anything happen after pressing it (the process runs in the background, invisible to the user).
      • Leave a minute or two to allow the course ends.
    • Restart your iPhone and your watch (turn the two together off the coast, then restart your iPhone first):
  • Insertion of records in two different tables at the same time?

    Hello everyone, I have question about inserting records in two different tables at the same time, I'm looking for is by the way a unique id, which is created in the first statement insert to the second insert statement. Example of this problem:

    < cfquery name = "addRecords1" datasource = 'test' >

    Insert Into Table1 (name, Date, age)

    Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.) "Name # ' >.

    < cfqueryparam cfsqltype = 'cf_sql_date' value = '#arguments. "Date # ' >.

    < cfqueryparam cfsqltype = "cf_sql_int" value = "#arguments. Age #"(>); "

    Select SCOPE_IDENTITY() as RecID;

    < / cfquery >

    < cfquery name = "addRecords2" datasource = 'test' >

    Insert into Table2(Company,City,Date,ID)

    Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.Company #" >,)

    < cfqueryparam cfsqltype = "cf_sql_char" value = "" #City # ">,"

    < cfqueryparam cfsqltype = 'cf_sql_date' value = "" #Date # ">,"

    ( < cfqueryparam cfsqltype = "cf_sql_int" value = "How to pass RecID to insert in this table?" >).

    < / cfquery >

    In this example, I'm inserting records in table 1 and creation of IDENTITY SCOPE as RecId. I would like to pass this id and insert it in my table 2. This Id, I'll use in my second table as an identifier. If anyone knows anything about this please let me know. Thank you.

    );
    

    QueryName - DOT - ColumnName, so it should be:

    );
    

    HTH,

    ^_^

  • Only GET records that have the same values of field has the same value in field B

    Have a hard time with below, please help.

    Here's the situation:

    create table cord (identification NUMBER, CM VARCHAR2 (3), PM VARCHAR2 (2));
    insert into string values (1, '002', 'H1');
    insert into string values (2, '006', 'H1');
    insert into string values (3, '004', 'H2');
    insert into string values (4, '006', 'H2');
    insert into string values (5, '004', 'H3');
    insert into string values (6, '004', 'H3');

    I just need to select the folders which, for the SAME value of PM have the same value in CM, in example above, those are recordings with ID (5,6).

    1 and 2 fail because for them CM and PM are different for the same H1, similar on the 3 and 4.

    I don't know if this will help but records are always in 'pairs', which means that there are no cases as

    7. '004' | H4

    8. ' 006' | H4

    9. '005' | H4

    Any ideas are much appreciated.

    Thank you

    See if the following can help...

    select id,cm,pm
        from(
            select t.*
                  ,count(1) over(partition by cm,pm) cnt
                from testt t
            )
        where cnt>1;
    
  • I just paid my creative service cloud for a month, but there is a problem with the service, is that someone has the same problem?

    I just paid my creative service cloud for a month, but there is a problem with the service, is that someone has the same problem?

    I paid with Paypal, which is linked to my debit card and already wait two days.

    Thanks to the community

    Please read https://forums.adobe.com/thread/1499014

    -try some steps such as changing browsers and disable your firewall

    -also clear the cache of your browser if you start with a fresh browser

    -check the file hosts for blocked entries https://forums.adobe.com/thread/1912777

    http://myleniumerrors.com/installation-and-licensing-problems/creative-cloud-error-codes-w ip.

    https://helpx.Adobe.com/creative-cloud/KB/creative-cloud-desktop-application-failed.html

    http://helpx.Adobe.com/creative-cloud/KB/failed-install-creative-cloud-desktop.html

    or

    Your subscription to cloud shows correctly on your account page?

    If you have more than one email, you will be sure that you use the right Adobe ID?

    https://www.adobe.com/account.html for subscriptions on your page from Adobe

    .

    If Yes

    Some general information for a subscription of cloud

    Cloud programs don't use serial... numbers you, connect you to your cloud account paying to download & install & activate... you may need to sign out of the cloud and restart your computer and log into the cloud for things to work

    Sign out of your account of cloud... Restart your computer... Connect to your paid account of cloud

    -Connect using http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html

    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html

    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html

    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html

    -ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp

    -http://helpx.adobe.com/creative-cloud/kb/license-this-software.html

    .

    If no

    This is an open forum, Adobe support... you need Adobe personnel to help

    Adobe contact information - http://helpx.adobe.com/contact.html

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    -Select your product and what you need help with

    -Click on the blue box "still need help? Contact us. "

  • List of user names and password which are the same

    Hello

    I created several user with the default password even under the user name. They are supposed to change their password. But some of them have not changed their password.

    Now, I want the list of these users of database that has the same password as their user name. How can I find it?


    I'm really grateful if you help me.

    Thank you
    API

    Oracle stores the password as a hash and the same two passwords will not have same hash value, so there is no way to query on the password. Do you not use profiles?

    All I can think of is to create a small script to connect to the database using various users, you have created with their default passwords and log if the connection succeeded or not. And then you can have a list of all successful connections which means, users who are not the default password changed again.

    Thank you
    Daljit Singh

  • I have 2 phones on my ID Apple how can I keep the two devices to receive the same iMessages?

    I have 2 phones on my ID Apple how can I keep the two devices to receive the same iMessages?

    How to use several devices iPhone, iPad or iPod with a computer

    Using more an iDevice on the same computer

    This mainly applies to couples who add another device and don't want their electronic mail, messages, etc. being duplicated on both devices. To start reading: How to use several iPhone, iPad or iPod devices with one computer. You must create a login separate Apple and password for anyone who will use the new iDevice. See Apple - my Apple ID and frequently asked questions about the Apple ID. The easiest way is to do it on the computer using iTunes: iTunes - how to set up an Apple ID iTunes.

    On the computer, create a new user account for the person with the new iDevice. This is the user account always uses this person. He or she will no longer use the other user account. This way the person will have a separate iTunes library. Note When finished, do not 'share' apps under a single Apple ID. Each of you must buy your own applications under your own Apple ID. When you decide to divide like this you will have to buy new applications they want to use.

    First, transfer the new devices to a new account as well as all your data.  Save pictures of flow picture you want to keep for your camera (unless they are already in the camera roll) by opening your Photos app, tap Albums icon at the bottom. Now press the album My Photo Stream; Press Select; tap the photo you want to select. tap the share (box with the face up arrow) in the lower left corner icon; in the film, and then click Save.

    If you synchronize notes with iCloud, you want to keep, you must open each of your notes and email it to yourself. Later, you can copy and paste the text into the new notes created in your new account.

    Tap Settings > iCloud > remove account (removes it only from this device, not iCloud; the person who maintains the current account is not affected) provide the password to disable find my phone and choose to keep on my iDevice when prompted.  Sign in with another Apple ID to create your new account. Choose merge to download your data.

    Once you are on separate accounts, you can each go to icloud.com and remove data from the other person to your account.

    The above was created by the user randers4. Changes were made to improve the readability and the syntax.

  • Two tasks that share the same resource in sequence

    I'm the current exception "the specified resource is reserved.". I understand that you can not run two tasks that share the same resource at the same time. However, is it true that you can not run two tasks that share the same resource, one right after the other, without the eliminate completely from the first task?

    for example

    Task1 and task2 share the same resource
    Task1. Start();
    Task1. Stop();
    Task2. Start(); This will always throw an exception until you have a task1 (i.e. task1.) Dispose()?
    Task2. Stop();

    Hi cafarm,

    You're right, the fact to just stop at one task does not allow that run you another task with the same resources immediately after. That being said, you can start the next task without having to erase or dispose of the first by making use of the task status template DAQmx. As you can see on the next page, stop a task simply going to the State of "Clerks", which means that the material is still used by the task even if she does not actively.

    http://zone.NI.com/reference/en-XX/help/370466AC-01/mxcncpts/taskstatemodel/

    Instead, you can use the control functionality of task for the first task of transition to the status "verified" after stopping it, then start the second task. This keeps the parameters of the task without having to have the task, but it should free up resources to be used by other tasks.
    http://zone.NI.com/reference/en-XX/help/370473H-01/mstudiowebhelp/HTML/verifycommitstartstopdaqtask/

  • Two background colors for the same waveform graph

    Hello guys!

    I have a question for you: I am a new user of labview, so please be nice!

    So here's the deal: I just created a thanks 4 thermocouple temperature registration program.

    In real time, I then have a waveform graph 4 curves as soon as I start my program. And in my program, I had a button that allows me to record the temperature in a file for a period of time at a certain frequency.

    So, what I have is: I got my chart of waveform with a black background for example, and once I pressed the button, the background color will be changed automatically to highlight the part of the graph where the record occurs, then the background will return to the black after finished recording. In this way, on the same graph, I could say that registration took place from here to there by looking at the graph. I have two different background on the same graph.

    I don't know how to change the background of a chart using the property node, but is it possible to do what I want?

    I hope I'm clear. Otherwise, feel free to ask me for more details... I might post my vi if necessary

    See you soon

    Well, I know this is not exactly what you want to do, but you can try the following.

    Change the color of the line on the chart when recording occurs.

    You could therefore have a red line, then press on save, then it turns blue, then back to red.

    And when that is confusing since you have 4 different lines on the chart 1,

    You can change to a red line and a dotted red line, for example.

    Would that be acceptable? If so, I can show you how to do this.

  • Trigger two FPGA instances at the same time

    I have a basic FPGA code that transmits the bits of data on a serial (RS-485) bus, the code is written so that it expects in the first State of a machine to States in a single-cycle timed loop.  After a certain trigger, he begins to read a FIFO containing data and sends the data on a line of Tx.  It does this until all bits are send and then it goes back to the first State to wait for the next trigger.  The relaxation is necessary because windows must fill out first before the FPGA FIFO can start sending.

    I need two instances of this code runs, because I have two buses of com (one is redundant).  So I use the FPGA code as a Subvi and I wrote a main FPGA vi to call two separate instances of the Subvi in parallel.  A regular window vi wrote on the FIFO for bed FIFO for Rx and Tx.  No problems so far.

    The thing is I start two transmissions in 200nS of each other (Yes, nanoseconds).  Windows will write two FIFO in parallel, but the timing is 4uS apart, too long.  I tried implementing a Boolean flag in the Subvi FPGA, but windows can not write directly on the control of Subvi.  FPGA won't allow (the Write function is grayed out).  I tried to use a FIFO for a flag, but the problem is a race condition.  One of the instances is first read FIFO and he destroy.  The other can't read.  I need a common trigger point to be used by the two instances of Subvi.

    My final solution was to use a memory in the Subvi FPGA and digital control in the main FPGA vi.  Windows write in numerical order, it may because the control is in the main FPGA vi.  Inside the main FPGA, I run a timed loop that looks for digital to be zero.  If so, it writes the value into the location of the memory used by the Subvi FPGA.  After awhile, the principal wrote a zero back to memory to prevent the Subvi is restarted, as well as to write a zero for digital to reset.  This repeats, waiting for windows to write in digital again for the next transmission.

    I had to do it this way because sometimes I want to pass on the bus, and sometimes just one or the other.  Numeric values are used to determine which to pass on.  Now, the transmissions are starting to almost exactly at the same time, 1 or 2 nanoseconds apart.  But the trigger process seems very silly to me.  I was wondering if there is a better solution.  I'm pretty new to FPGA.

    tbob wrote:

    Basically, I did the same thing using FPGA memory.  Windows I am writing for a digital control that resides inside the main FPGA vi.  In the main FPGA, I write in the memory.  Inside the Subvi FPGA, I read the brief and decode the value to use either one or the other or both buses.  After fool with it for awhile, because reading Memeory needs to use a shift register (probably because it takes a whole cycle of clock), I had to work.  The two bus trigger at the same time.  I guess it's not really important if I use a FIFO or if I use the memory.  The main problem is that I write Windows at the hand of FPGA, then the hand of FPGA for the Subvi FPGA.  Then the time is right for what is the Subvi is.

    There are some advantages to the use of two FIFO on your approach.  First of all, you don't have the change of register for the memory location.  Secondly, we should not worry that VI is responsible for compensation to the memory location, or do, you run the risk that one of your subVIs run twice, or not at all, if the memory is not erased at the right time.  Perhaps most important, you'll save yourself space on the FPGA because you will not need arbitration - the additional code that is added when two parts of the FPGA try to access the same resource at the same time.  In your case, both instances of the Subvi access the memory block at the same time, so the FPGA compiler adds additional logic to avoid conflict.  If only read you the memory block in one place and just write it in one place (reading and writing can be different loops where subVIs) there is no need for arbitration.  Using two FIFOs, you can keep independent and avoid the conflict resolution code.  See the help for the "arbitration" for more details.

Maybe you are looking for