MERGE TWO COLUMNS?

Hi, I asked about my database, as follows,

< pre >
SELECT
C.LKP_ID ID, D.LKP_ID ID, C.ROOT_CAUSE_CODE CODE, D.PART_DISPOSTN_DESC CODE ACE ACE ACE
Of
(
SELECT DISTINCT
A.LKP_ID AS LKP_ID
D.PART_CNDTN_CD as ROOT_CAUSE_CODE
C.LKP_NM as ROOT_CAUSE_DESC
A.CREATED_DT AS OD_CREATED_DATE
A.UPDATED_DT AS OD_LAST_UPDATED_DATE
CREATED_DATE AS CURRENT_TIMESTAMP,
LAST_UPDATED_DATE AS CURRENT_TIMESTAMP
OF FWOWNER. CLM_LKP_VALUE A, FWOWNER. CLM_LKP_USAGE B, FWOWNER. CLM_LKP_VALUE_LANG C.
IWOWNER. WC_CLM_SRVC_PART D
WHERE B.LKP_USED_AS IN ('RR_CAUSAL_PART_CNDTN_CODE')
AND A.LKP_REF BETWEEN B.LKP_REF
AND B.LKP_REF + '.' 99999 and A.LKP_ID = C.LKP_ID
AND C.LANG_CD = 'ENG_USA. '
AND A.LKP_LVL = 3
and D.PART_CNDTN_CD = A.LKP_VALUE
) C

CROSS JOIN

(
SELECT DISTINCT
A.LKP_ID AS LKP_ID
D.PART_DISPOSTN_CD as PART_DISPOSTN_CODE
C.LKP_NM as PART_DISPOSTN_DESC
A.CREATED_DT AS OD_CREATED_DATE
A.UPDATED_DT AS OD_LAST_UPDATED_DATE
CREATED_DATE AS CURRENT_TIMESTAMP,
LAST_UPDATED_DATE AS CURRENT_TIMESTAMP
OF FWOWNER. CLM_LKP_VALUE A, FWOWNER. CLM_LKP_USAGE B, FWOWNER. CLM_LKP_VALUE_LANG C.
IWOWNER. WC_CLM_SRVC_PART D
WHERE B.LKP_USED_AS IN ('rr_parts_disposition')
AND A.LKP_REF BETWEEN B.LKP_REF
AND B.LKP_REF + '.' 99999 and A.LKP_ID = C.LKP_ID
AND C.LANG_CD = 'ENG_USA. '
AND A.LKP_LVL = 3
and D.PART_DISPOSTN_CD = A.LKP_VALUE
) D

< / pre >

which gave rise to:


< pre >
ID CODE ID CODE
----- ----- ------- ----------
25768 28225 REVAMPED CP01
25771 28225 CP04 REVISED
25774 28225 REVISED CP07
25777 28225 CP10 REVISED
25778 28225 REVAMPED CP11
25779 28225 REVAMPED CP12
25780 28225 REVAMPED CP13
25781 28225 REVAMPED CP14
25783 28225 REVAMPED CP16
25785 28225 REVAMPED CP18
25786 28225 REVAMPED CP19
25788 28225 REVAMPED CP21
25789 28225 REVISED CP22
25790 28225 REVAMPED CP23
25793 28225 REVAMPED CP26
25795 28225 REVISED CP28
25796 28225 REVAMPED CP29
25797 28225 REVAMPED CP30
25798 28225 REVISED CP31
25799 28225 REVAMPED CP32

20 response (s) selected [extract metadata: 0/ms] [extract data: 0/ms]

< / pre >

I need to merge the two ID and Code that can bring 21 records, how to do this, please help me



Concerning
Naren.

Hi, Naren,

Whenever you have a problem, it helps if you pst a small example data (CREATE TABLE and INSERT statements, elevenat columns only) and the results you want from this data.

I suspect you want to do something like this:

SELECT  A.LKP_ID          AS ID
,     D.PART_CNDTN_CD          as CODE
FROM     FWOWNER.CLM_LKP_VALUE          A
,     FWOWNER.CLM_LKP_USAGE          B
,     FWOWNER.CLM_LKP_VALUE_LANG      C
,     IWOWNER.WC_CLM_SRVC_PART     D
WHERE     B.LKP_USED_AS          IN ( 'RR_CAUSAL_PART_CNDTN_CODE'
                       , 'rr_parts_disposition'
                       )
AND     A.LKP_REF          BETWEEN     B.LKP_REF
                    AND     B.LKP_REF + .99999     -- No quotes
and     A.LKP_ID          = C.LKP_ID
AND     C.LANG_CD          = 'ENG_USA'
AND     A.LKP_LVL          = 3
and      A.LKP_VALUE          = CASE
                         WHEN  B.LKP_USED_AS     IN ( 'RR_CAUSAL_PART_CNDTN_CODE')
                         THEN  D.PART_CNDTN_CD
                         WHEN  B.LKP_USED_AS     IN ('rr_parts_disposition')
                         THEN  D.PART_DISPOSTN_CD
                      END
;

or maybe a UNION instead of a join.

Published by: Frank Kulash, February 9, 2010 09:08
Revised the last condition.

Tags: Database

Similar Questions

  • Merge two column in single column value

    Team,

    I have a requirement where in I need to merge 2 column values in a single column.

    e.g. I Percent_complete column in my table. and my table has only one record.

    I need to ask questions that I need to store the values of percent_complete and (100-percent_complete) in a single column.

    ex

    Percentage complete is set to 30.

    I need to select the 30 and 70 (100-30) both in a single column.

    Thank you

    If you mean like this?

    SQL > ed
    A written file afiedt.buf

    1 with t (select 30 as double percent_complete)
    2  --
    3 end of test data
    4  --
    5. Select decode(rownum,1,percent_complete,100-percent_complete) as percent_complete
    6 t
    7 * connect by rownum<=>
    SQL > /.

    PERCENT_COMPLETE
    ----------------
    30
    70

  • Merge two schemas

    Hello

    Oracle11.2.0.1.0 < /p >

    RHEL5

    I landed in a situation where I have to merge two schemas in different databases.

    Schema name is the same, the Table names are also same on two patterns

    The only difference that could be in the diagrams is the data within these tables.

    What we want is that when importing data into a table, if the primary key already exists in the target table, then it should update the primary key of the table source with the max value + target 1 of the primary key for the table.

    Also tables would be having a lot of constraints attached to them.

    So, here I just wanted to have little guidance on the scenario of the gurus of the oracle

    I landed in a situation where I have to merge two schemas in different databases.

    Schema name is the same, the Table names are also same on two patterns

    The only difference that could be in the diagrams is the data within these tables.

    What we want is that when importing data into a table, if the primary key already exists in the target table, then it should update the primary key of the table source with the max value + target 1 of the primary key for the table.

    Also tables would be having a lot of constraints attached to them.

    So, here I just wanted to have little guidance on the scenario of the gurus of the oracle

    Even though I think I understand what you're SAYING you want to do I am not at all convinced that you should actually do.

    The integrity of the data - you will simply ignore this aspect of the problem?

    This guarantees that the lines corresponding to a key value of substitution even remotely represent the same real data set. For example, a customer table may use a sequence to a surrogate key, but a key value of 23 in a pattern table can be a totally different person from the person with the key value of 23 in the other schema.

    Further - even if the same person IS represented, the other columns/attributes can be different. Someone may have changed of name, address, telephone or any other piece of data. So now you would just be throwing the source line because it has the same substitution as a line existing target key.

    Frankly I do not know any business user I've ever worked with who would take that kind of risk.

    Even to do what you say you want, you do it in an operation of "import". You load data into a work table, and then retrieve data that do not have an existing key value in the target table.

    My recommendation is that you, or someone, to prepare a detailed functional requirements document that addresses ALL potential problems with data integrity that might arise and explains how business users want to treat.

    If you do that you are virtually guaranteed to corrupt your data. In addition to corruption will be such that it will be very difficult to know what was the source of any particular data item.

  • 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.

  • common two-column name

    Hello
    IM new to OBIEE and have aquestion on reports in OBIEE answers.

    I need to put a common two-column name, while retaining the existing column name. The common column name should apprear on the actual column name defined above.
    Is this possible in OBIEE?
    Thank you

    The merger is simple giving two colomns the very title of the table:
    both are now my columns:
    ! http://img526.imageshack.us/img526/7345/tableheading02.jpg!
    ! http://img526.imageshack.us/img526/7345/tableheading02.jpg!
    Put just the allignment of the header:
    ! http://img148.imageshack.us/img148/663/tableheading04.jpg!

    Concerning

    John
    http://www.obiee101.blogspot.com/

    Published by: John Minkjan February 5, 2010 02:57

  • queries mergeing two in single query? Thank you!!!

    Hello gurus,

    How to merge below two queries in a single request. All the I'm trying to do is get the acc_office_id and the pay_office_id... We want it in two different columns because the office for access and compensation IDs are in the same column. .so I m try to divide it into two columns.

    Any help is greatly appreciated... Thank you very much!!!



    -request for VAC office_id

    Select acc.cust_id cust_id,
    RO.office_id acc_office_id,
    ACC.office_cd office_cd,
    ACC.type_cd type_cd
    of refoff ro,.
    (select distinct f.cust_id cust_id,
    f.type_cd type_cd,
    f.office_cd office_cd
    cutomer p,
    Office f
    where p.cust_id = f.cust_id
    and f.type_cd in ('ACCT')) VAC
    where acc.office_cd = ro.office_cd;


    -request for pay office_id


    Select bill.cust_id cust_id,
    RO.office_id acc_office_id,
    Bill.office_cd office_cd,
    Bill.type_cd type_cd
    of refoff ro,.
    (select distinct f.cust_id cust_id,
    f.type_cd type_cd,
    f.office_cd office_cd
    cutomer p,
    Office f
    where p.cust_id = f.cust_id
    and f.type_cd in ("wages")) pay
    where pay.office_cd = ro.office_cd;

    Hello

    SELECT       c.cust_id
    ,       MAX (CASE WHEN c.type_cd = 'part1' THEN o.office_cd END)     AS par1_offc_id
    ,       MAX (CASE WHEN c.type_cd = 'part2' THEN o.office_cd END)     AS par2_offc_id
    ,       MAX (CASE WHEN c.type_cd = 'part3' THEN o.office_cd END)     AS par3_offc_id
    FROM       cust_office     c
    JOIN       office     o     ON     c.office_cd     = o.office_id
    GROUP BY  c.cust_id
    ;
    

    The output I get from your sample data is a little different from what you have posted:

    CUST_ID    PAR1_OFFC_ID    PAR2_OFFC_ID    PAR3_OFFC_ID
    ---------- --------------- --------------- ---------------
    2001       10              10              10
    2003       12              14
    2002       11              11              12
    2004       13              13              15
    

    If the differences are not due to errors in your message, explain how you get correct results.

  • Number of matches between two columns

    Column1 Column2
    5 5
    5 2
    5 5
    4 3
    4 4
    Football match
    3

    I basically you want to compare two columns and count matches in the corresponding lines. I tried using the following formula:

    SUMPRODUCT (--($column1=$column2))

    ... but it doesn't work! Any suggestion?

    Tiago,

    It seems you are trying to use array formulas (maybe since excel?) who do not work in number.

    Here's how I would solve this problem:

    Make sure that the table where data is named 'Data' (as shown, or change the table name references to match your table name)

    Add a new column (C)

    C2 = AND (A2 = B2, A2≠ "")

    It's shorthand dethrone select cell C2, then type (or copy and paste it here) the formula:

    = AND(A2=B2, A2≠"")

    Select cell C2, copy

    Select cells C2 at the end of the C column, paste

    the formula say to check to see if the cell in column A is NOT empty, and is equal to the cel in column B

    Now in the summary table (single cell table):

    A1 = COUNTIF (Data::C, TRUE)

  • Does anyone know how to merge two workseets number for printing?

    How can I combine two spreadsheets in numbers for printing?

    Hi jj,

    I assume that you mean that you have a single document, which contains two worksheets, and that each sheet contains one table (only?).

    What do you mean by "merge two (booklets)?

    You mean you wan to place Tables of two leaves on a single sheet (this sheet would contain then both tables).

    Or do you mean you want to place all data on the two tables into a single table on one sheet?

    Or do you mean something different to both of these descriptions?

    Kind regards

    Barry

  • iBooks/iPad two columns per page

    Since this morning after an update to the iPad, iBooks is showing the book pages in two columns instead of a full page, from left to right.  How can I change this back to a page on the screen?

    I saw that too. Stupid solution. Increase your font a to the top of the smallest.

    The smaller police apparently goes into two columns.

  • Compare two columns and get the percentage of cells that match

    Hello

    I'm looking to take two columns of data from different tables in the same document, which should have a high enough percentage of boxes and have another cell tabulate the corresponding percentage. I can the of seem to figure out how to do this, but it seems really possible.

    Any help is greatly appreciated.

    Thank you!

    C1 = A1 = B1

    It's shorthand dethrone select cell C1 and type (or copy and paste it here) the formula:

    = A1 = B1

    Select cell C1, copy

    Select the column C, paste

    Select cell E2, and then type 'TRUE '.

    Select cell E3 and then type "FALSE".

    F2 = COUNTIF ($C, E2)

    F3 = COUNTIF ($C, E3)

    G2 = F2÷SUM(F$2:F$3)

    G3 = F3÷SUM(F$2:F$3)

  • How to view the menu of bookmarks in two columns

    Firefox 3.6.7 under Windows 7. I wish I had the menu bookmark appears in two columns to avoid the bottom of the scroll list.

    Sorry, it's not a function for this integrated into Firefox.

    See if this extension fits your needs.
    https://addons.Mozilla.org/en-us/Firefox/addon/74381/

    Read all the comments from the user before installing it, there might be a problem on Win7 or with later versions of 3.6. versions #.

  • Combine the two columns of text

    I have two columns of text (say that name is a column and the name is the other)

    I would like to combine the two columns for the text of these two columns are in a column. (First name and last name in the same column)

    Is this possible? If so is there a tutorial somewhere?

    Hi Danielle,

    The & (concatenation operator) is your friend.

    Formula in D2 (fill down)

    "B2 &" "& C2.

    & joins elements into a single string.

    "" inserts a space.

    Kind regards

    Ian.

  • How to compare two columns in Xl

    I want to compare two columns in the file of Xl. column A contains phrases and column B contains the words

    For example

    Column A                                                                       Column B                                                                           Column C

    I have an Apple and I'll eat every day Apple Apple

    I have a banana and eat weekly banana papaya

    Oranges are rich in nutritions cauliflowers Oranges

    Papaya is good for health                                               Grapes                                                                                 Papaya

    Oranges

    Lichi

    Banana

    I want to check each value of column B in each cell in column A, and if it matches then it should return the corresponding value in the result to me. Column C should Look Like as shown above.

    Can someone point me in the right direction here of what formula to use for this Xl.

    Thank you

    This is a forum for Mac OS X technologies, so here's an Applescript solution:

    1. Copy-paste the script in the Script Editor
    2. Select the cells in columns A and B
    3. Command + c to copy to the Clipboard
    4. Click on the button "run" in the Script Editor
    5. Click once in the top cell in column C where you want the data
    6. Command + v to paste

    Here are the results:

    There is no verification error here. You must select and copy to the Clipboard before the race.

    SG

    the value LstOfLsts to makeListOfLists (the Clipboard as a 'class utf8 ')

    the value theSentences to getCol1Vals (LstOfLsts)

    the value collected in getCol2Vals (LstOfLsts)

    game of theMatches to «»

    Repeat with I in collected items

    If theSentences contains I then ¬

    the value of theMatches to theMatches & i & return

    end Repeat

    Set the Clipboard for theMatches

    to getCol1Vals (LofL)

    game of col1Vals to «»

    Repeat with en LofL points

    the value col1Vals to the col1Vals & "" & i point 1

    end Repeat

    end getCol1Vals

    to getCol2Vals (LofL)

    the value col2Vals to {}

    Repeat with en LofL points

    If i's point 2 is not "" then ¬

    i copy point 2 to the end of col2Vals

    end Repeat

    return col2Vals

    end getCol2Vals

    at makeListOfLists (theTxt)

    value was to theTxt paragraphs

    the value text point of delimiters

    the value theListOfLists to {}

    Repeat with I from 1 to count was

    the value theListOfLists to the theListOfLists & {the was point i text elements}

    end Repeat

    the value point text delimiters to «»

    return theListOfLists

    end makeListOfLists

  • How to merge two slideshows macOSX

    I'm trying to merge two slideshow on my mac Pro or Imac. If possible, I would like to keep the original music in both. But it is not critical.

    Thank you

    Slide show projects cannot be merged.

    If you visit both attractions like a video, you can add the two points of view in iMovie and display a merged video.

    Otherwise, duplicate a slide show and add photos of the second presentation to the other.

    What version of iPhoto do you use?

  • How to read the two columns of data in a file of PDM.

    Hi all

    I am reading two data columns for the 2nd of a PDM file two sheets, as shown below.

    Two columns of data must then be shared so they can be displayed in a xy chart and also apply a linear adjustment VI. I implemented the graph xy and linear adjustment using a txt file (see below), therefore all the outputs work, however this application with a tdms file turns a little more tax.

    So, essentially, that I don't know how read the correct leaf and therefore the columns in the PDM file and then how to produce the graph xy and linear adjustment of the data types produce. Here's my current attempt, which produces several errors of the type of terminal, as well as not being able to select the exact data in the PDM.

    Any help/suggestions/example vi on this asap would be greatly appreciated.

    Thanks in advance,

    Pete

    Also the PDM file viewer. VI helps you easily understand the structure of data files.

Maybe you are looking for

  • Why Mozilla Firefox opens at a previous session?

    Whenever I run Mozilla Firefox, a session for a little over a week ago opens. Usually it opens on my home page. Now, he opens with 8 tabs. They are: My Yahoo, my Gmail mail, 4 other Google sites and a site of Amazon.How can I put a stop to this?Thank

  • Widespread problem "Firefox is already running" suggests it does not close properly - is Mozilla solve this?

    Several people including me have reported a problem when closing Firefox and then try to re - open. The message "FF is already running and should be closed... ' appears, but the taskbar does not display an active FF. At this point, it is necessary to

  • Tecra A3 freezes at loadup windows screen

    Hello, I was wondering if someone can help me I have a problem with my laptop that I turned it off as usual last night, but this morning when I turned on it boots like normal it gets to the windows loading screen then a blue screen appears, but I can

  • Installed El Capitan, Mac Mail not loading and computer works slower

    It is now a week now since the installation and Mac Mail is still not loading new emails automatically. When I exit and restart the mail, the titles of all new e-mails comes in but not the content. In order to get the content I did some random action

  • HP 350 G1: Synaptics Luxpad v7.5

    After you have installed the latest driver from synaptics site v17.0.19, when I open the properties of the touchpad I can't text and illustrations as if a plugin is missing. Any ideas? Thnx