Merging Records with same or NULL values

Hi,
create table AS_ITM (id_itm NUMBER, diff_1 VARCHAR2(20), diff_2 VARCHAR2(20));
insert into as_itm values (22188212, 'J068', 'C001');
select id_itm, diff_1, diff_2 from as_itm;
output:
22188212     J068     C001
create table RK_DIFF_DESC (diff_id VARCHAR2(20), diff_type VARCHAR2(20), diff_desc VARCHAR2(20));
insert into RK_DIFF_DESC values ('C001', 'C', 'Red');
insert into RK_DIFF_DESC values ('J068', 'S', '6.8gm');
select diff_id, diff_type, diff_desc from RK_DIFF_DESC;
output:
C001 C     Red
J068     S     6.8gm
Now I am writting a query to get the out put ::
SELECT i.id_itm,
i.dept_id,
CASE WHEN (DIFF.DIFF_TYPE = 'S') THEN diff.DIFF_DESC ELSE NULL END
AS SIZE1,
CASE WHEN (DIFF.DIFF_TYPE = 'C') THEN diff.DIFF_DESC ELSE NULL END
AS COLOR
FROM as_itm i
LEFT OUTER JOIN
RK_DIFF_DESC diff
ON (i.diff_1 = diff.DIFF_ID OR i.diff_2 = diff.DIFF_ID);
output:
ID_ITM     DEPT_ID     SIZE1     COLOR
22188212     4103      6.8gm     
22188212     4103          Red
My requirement is to get a single record like this:
ID_ITM     DEPT_ID     SIZE1     COLOR
22188212     4103      6.8gm     Red
I can do this joining RK_DIFF_DESC two times with AS_ITM using below query.
SELECT a.id_itm,
a.dept_id,
b.diff_desc size1,
c.diff_desc COLOR
FROM as_itm a
LEFT OUTER JOIN RK_DIFF_DESC b
ON (a.diff_1 = b.DIFF_ID AND b.diff_type = 'S')
LEFT OUTER JOIN RK_DIFF_DESC c
ON (a.diff_2 = c.DIFF_ID AND c.diff_type = 'C')
Is there any other way to merge the above two lines into one joining RK_DIFF_DESC only 1 time ?
..............................

select id_itm, max(SIZE1) SIZE1,  max(COLOR) COLOR
from
select id_itm,
        case diff_type when 'S' then diff_desc end SIZE1,
        case diff_type when 'C' then diff_desc end COLOR
from AS_ITM a, RK_DIFF_DESC r
where diff_1 = diff_id or diff_2 = diff_id
group by id_itm;
    ID_ITM SIZE1                COLOR              
  22188212 6.8gm                Red                
1 row selected.

Similar Messages

  • Duplicate record with same primary key in Fact table

    Hi all,
       Can the fact table have duplicate record with same primary key . When i checked a cube i could see records with same primary key combination but the key figure values are different. My cube has 6 dimentions (Including Time,Unit and DP) and 2 key figures. So 6 fields combined to form the composite primary key of the fact table. When i checked the records in se16 i could see duplicate records with same primary key. Ther are no parallel loading happening for the cube.
    BW system version is 3.1
    Data base is : Oracle 10.2
    I am not sure how is this possible.
    Regards,
    PM

    Hi Krish,
       I checked the datapacket dimention also. Both the record have same dimention id (141). Except the Keyfigure value there is no other change in the Fact table record.  I know this is against the basic DBMS primary key rule. But i have records like this in the cube.
    Can this situation arise when same records is there in different data packet of same request.
    Thx,
    PM
    null

  • New info record with same details as archive one.

    Hi Experts,
    Due to some issue we want to archieve some standard info record which are created on vendor / material group / plant  basis.My query is does system allows to create new info record with same vendor / material group / plant combination after archiving earlier record which is on same basis.
    Thnaks & Regards
    Vinay

    Hi Jurgen,
    Thanks for reply.
    Our issue is while creating work order(IW31) having external services upon entering info record number in some cases in same client rate is picked up from info record condition but some times from last purchase order based on info update.
    We have checked following points.
    1.In all the cases work order type  is same.
    2.Info record are of standard type with same condition.info record are for vendor & material group combination.
    3.Checked after changing rate in info record and in purchase order but similar issue exists
    4.Compare vendor master also.
    5.Their are no contract /sch.agreement for vendors.
    Our requirement is to have rate from info record in all the cases in work order.So have two options.
    1.Archiving info record-But will need setting in SPRO and also need to create same record again with same combination.Also as their are recent purchase order against those info record not sure whether system will allow or not.Can you please tell what are prerequiste for archiving info record.
    or
    2.To remove only purchase order number updated in EINE table in those info record where this issue is occuring.We have checked in development system and after removing purchase order number in EINE table it picks up rate from info record.
    So thought of checking before removing order ref.from EINE table.
    Thanks
    Vinay

  • Error Record with Same Key

    Can anyone help me out with a master data load failure.
    My request goes off red and the message looks somehow like "Record filtered in advance as error records with the same key exist", "Filter out new records with same key". I have already checked the duplicate handle record setting in DTP. Still why am i getting this error.
    Would appreciate if some one could suggest me in this.

    Hello Shridevi M ,
    When I execute my DTP, I get a master data load failure : "Record filtered in advance as error records with the same key exist" . It's the same as you get. Please tell me how did you solved this probelm?
    Thanks in advance,
    Abdellatif

  • When we click on the copy botton record with same name should not be saved

    Hi,
    Copy button will copy the record with the same name and will save it.our requirement is when we click on the copy botton ,record with same name should not be saved
    we are performing this task in custom object 12 and exposed Opportunity Name in the layout.
    Records with same Opportunity Name should not save ..when we copy the record
    Can we perform any field validation on Opportunity Name field?
    Please help
    please email me @ [email protected]
    Thanks
    Srinivas Merugu

    Opportunities that are assoicated to the same account cannot have the same name. You cannot make this unique for your whole instance. The only way that you could do this would be to create a webservice application that checks this before you save the record.
    What about defaulting the name each time this could make the record unique?

  • Purchase info record with same values

    Hi,
    I want to create purchase info records with the same material vendor purchasing org. plant ,how can it be done.
    This is required because it is possible for the same vendor to deliver material for the same plant and purchasing organisation.Is there a workaround or any reason for this.
    Regards

    In SAP , this is not possible to have 2 different inforecords for the combinaiton of MaterialVendorPur orgPlantinfo record type
    could you please explain more regarding the requirement ....
    Regards
    Mani

  • Problem with QofQ and Null Values

    Just converted from CF5 to CF7. Finally figured out what was
    causing the error message :
    "The value "" cannot be converted to a number" when running a
    QofQ. It happens whenever there is a NULL (and I think a ZERO)
    value in the QofQ. I'm using the QofQ in a seperate chart program.
    The main query merges data from a store and a region table.
    I'm doing a LEFT OUTER JOIN to combine the REGION with the STORE,
    AND so that stores with NO SALES for a given day will show up as
    ZERO. On the main report, when I don't use a QofQWhen grouping by
    DAY or MONTH, I can test the value in the CFOUTPUT for NULL or ZERO
    and display "0" or "N/A" on the report.
    But when I try to chart it, using a QofQ to read in the
    values from the main query, and format the numbers, I get this
    error message. I've tried using the CAST function, using FLOAT,
    DOUBLE, BIGINT, etc., but still get same error message.
    The only way I could fix this is to add a WHERE statement to
    the QofQ, that only includes sales values greater than ZERO. But
    then, I have gaps in my chart because stores with NO SALES for a
    given day or MONTH don't appear. Because they are removed from the
    query. The whole point of LEFT JOINS is to include items with no
    values (or NULL) values.
    Does anyone know if it's possible to keep these values in a
    QofQ? So that items (e.g., store locations in my case) with NULL or
    ZERO values for some or all days or months can be charted? Even
    with a ZERO value? I've read everything I can get my hands on
    regarding QofQ, the CAST function, etc., but nothing seems to work.
    Thanks for any help. (FYI, didn't have this problem with CF5. It's
    QofQ could handle NULL or ZERO values without providing an error).
    Gary

    Well, I tried the IsNull function on the 3 SUM() values I was
    calculating in my SELECT statement (on a LEFT OUTER JOIN QUERY),
    and I STILL got another "cannot convert "" to a number" but this
    time the error message was more direct, and pointed me to a DATE
    field in my query, where I was SORTING AND GROUPING either by DAY
    or MONTH (depending on what user selected on form).
    In my QofQ, I'm not just reformating the integer SUM()
    values, but also the date values. So, I applied the IsNull()
    function to the DATE values in my main query. I still kept getting
    errors. But after experimenting ((SQL Server BOL docs doesn't give
    ISNULL() examples for DATE FIELDS, only NUMBER fields), I tried
    putting the dates in SINGLE QUOTES in my IsNull() function, the
    QUERY RAN. Then I wasn't sure WHAT date to enter, e.g., 1/1/1889 or
    1/1/2001, etc.
    Then, I discovered, after experimenting, that you cannot just
    blindly enter ANY date when using IsNull in a date field,
    especially if you are using CFGRAPH to chart the results by day.
    You have to select a date within the date range the user selected,
    so this means using the FORM.DATE (or URL.DATE) value from the
    form. Here's the working example from my SELECT main query:
    SELECT SUM(ISNULL(d.ttldb,0)) AS SumOfDB,
    SUM(ISNULL(d.ttldbv,0)) AS SumOfDBV,
    SUM(ISNULL(d.ttldbi,0)) AS SumOfDBI,
    <CFIF '#url.reptype#' IS "DAILY">
    ISNULL(d.depday, '#url.date1#') AS depday
    <CFELSE>
    month(ISNULL(d.depday, '#url.date2#')) AS TranMonth,
    year(ISNULL(d.depday, '#url.date2#')) AS TranYear
    </CFIF>
    Then I discovered that whatever date was used in the URL.DATE
    field (in my case it would be one of the two date field from the
    form, and depended on whether you coded DATE1 or DATE2, the chart
    would always show ZERO values for that date. So I tried putting the
    IsNull() date values in the GROUP BY and ORDER BY statements, e.g.,
    <CFIF '#url.reptype#' IS "DAILY">
    GROUP BY ISNULL(d.depday, '#url.date1#')
    ORDER BY ISNULL(d.depday, '#url.date1#') DESC
    <CFELSE>
    GROUP BY year(ISNULL(d.depday, '#url.date2#')),
    month(ISNULL(d.depday, '#url.date2#'))
    ORDER BY year(ISNULL(d.depday, '#url.date2#')),
    month(ISNULL(d.depday, '#url.date2#'))
    </CFIF>
    And this worked. The report ran just fine, and the chart
    charted every value correctly.
    I guess you have to learn all the little "quirks" about CF7
    and how it's QofQ and chart programs work. But so far, so good.
    Thank you all for your help. Now I've got to update other old
    CF5 programs that are returning errors when there are null values
    from my LEFT OUTER JOIN queries. Will take some time, but at least
    I know how to do it. Thanks to your help.
    I really appreciate your time and efforts to help with this
    issue.
    Gary

  • Unable to query records with data in exponential value ? ?

    Hello,
    I have a strange problem here, hope someone can answer my query.
    I have 2 tables where the 1st col is a seq with datatype NUMBER(22) and NOT NULL constraint. Now, the value within that col is quite large and hence when I query the table in TOAD/SQL developer it displays output in exponential form. Now the issue is this, In one table I'm able to find/search a particular row by using the exp value within where clause and the same is not possible in other table.
    The sample data is here.
    I'm able to search record by using the below values in 1 table but same is not possible in another.
    1200000211600013
    1.20000021160001E15
    Can anybody tell me what could be the possible reason for this or where should I look for to find an answer?
    Thanks in Advance!!
    Toufiq

    Seems there's no problem in Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    with
    numbers as
    (select 1200000211600013330 the_number from dual union all
    select 1200000211600013333 from dual
    select n.the_number,s.search_string
      from numbers n,
           (select :your_number search_string
              from dual
           ) s
    where n.the_number(+) = to_number(s.search_string)
    THE_NUMBER
    SEARCH_STRING
    1200000211600013333
    1200000211600013333
    THE_NUMBER
    SEARCH_STRING
    1200000211600013333
    1.200000211600013333E18
    THE_NUMBER
    SEARCH_STRING
    1200000211600013333
    12000002116.00013333E+8
    THE_NUMBER
    SEARCH_STRING
    1200000211600013330
    1.20000021160001333E+18
    THE_NUMBER
    SEARCH_STRING
    1.20000021160001333E17
    Even implicit conversion seems to work
    select n.the_number,s.search_string,dump(s.search_string,16) search_dump,dump(n.the_number) result_dump
      from numbers n,
           (select :your_number search_string
              from dual
           ) s
    where s.search_string = n.the_number(+)
    THE_NUMBER
    SEARCH_STRING
    SEARCH_DUMP
    RESULT_DUMP
    1200000211600013330
    1.20000021160001333E18
    Typ=1 Len=22: 31,2e,32,30,30,30,30,30,32,31,31,36,30,30,30,31,33,33,33,45,31,38
    Typ=2 Len=11: 202,2,21,1,1,22,17,1,2,34,31
    Regards
    Etbin

  • Error in sharepoint external list while creating record with same id (this id is primary key)

    Hi,
    I have created one external content type in sharepoint designer to insert/update/delete table data.
    This table contains Primary key constraint.
    Then I have added this external content type to Sharepoint out of box List.
    Insert/Update/Delete is working fine. But when I am trying to insert record with the same id which is already exist in table, page crashed and its giving me following error:
    “Violation of PRIMARY KEY constraint 'PK_tbl_Accounts'. Cannot insert duplicate key in object 'dbo.tbl_Accounts'.
    The duplicate key value is (1). The statement has been terminated.”
    So I want to handle this exception. Can we show any popup message to hide this error?
    Thanks & Regards
    Rajni

    Avoid entering of primary from form  if possible.
    if not try to customize the new form with infopath and place your custom logic there.
    http://lightningtools.com/uncategorized/modifying-external-list-forms-with-infopath-2010/
    http://salnikan.wordpress.com/2011/07/26/prevention-of-duplicate-entries-based-on-two-or-more-columns-in-a-sharepoint-list/
    Bala

  • Two records with same  key (Infocube)

    Hi,
    I was trying to do, in a update rule, an "IF" condition with two key figures.
    IF Kf1 > Kf2. result = Kf1 else result = Kf2.
    But the data in the source (datamart Infocube to infocube) have tow records with the same characteristics combination (the same keys)and different amount in the keyfigures, then the result of my "if" condition is not the expected because I understood in the infocube only exists one characteristics combination. :S
    I was seeing those records in the manage transaction of the infocube.
    Some reason for this?
    Thanks and regards
    Victoria Leó

    This can happen with parallel loads.  Two rows with same set of Char values but in different packets of the same Request, being loaded at the same time.
    It really shouldn't be an issue - your update rule will make the KF change as desired.  Your queries aggregate KFs based characteristic values, not Dim IDs, so you'll get the totals you expect.
    Here's some more info:
    There is an RSRV Test that lets you check a dimension for a cube to see if multiple DIM IDs exist for the same combination of Chars - <b>Multiple Entries in Dimensions of a (Basis) InfoCube</b>
    Output looks like:
    12:02:24 o'clock on 08/25/2006: Start test run for user PIZZAMAN:)
    Dimension ZFM_C521: DIMID 61,215 and 61,214 have same characteristic values
    Dimension ZFM_C521: DIMID 61,880 and 61,879 have same characteristic values
    Dimension ZFM_C521: DIMID 61,366 and 61,365 have same characteristic values
    Dimension ZFM_C521: DIMID 61,368 and 61,367 have same characteristic values
    12:02:24 on 08/25/2006: Test run for user PIZZAMAN:) completed
    You can run the Correct Error option to have it update fact rows to use one of the DimIDs if you want, but unless you have lots of them, I even wouldn't bother.
    Here's the description of the test:
    <u>Description</u>
    This elementary test recognizes whether there are several lines that have different DIMIDs(dimension table key), but have the same SIDs for the selected dimension table for the InfoCube specified. (This can occur by using parallel loading jobs). This has nothing to do with an inconsistency. However, unnecessary storage space is occupied in the database.
    <u>Repairs</u>
    Since the different DIMIDs with the same SIDs are normally used in the fact tables, they cannot simply be deleted. Therefore, all of the different DIMIDS in the fact tables are replaced by one DIMID that is randomly selected from the equivalent ones. Before a change can be made to the database, the consent of the user is requested.
    DIMIDs that have become unnecessary are deleted in the connection. In doing so, not only are the DIMDs deleted that were released in the first part of the repair, but so are all of those that are no longer used in the fact tables (including aggregates). The consent of the user is again requested before this change is made.

  • Query to get the records with same last name

    I need to write a single sql query to get all records with duplicate last_name's. For example, if tab1 has 4 records:
    10     Amit     Kumar
    20     Kishore          Kumar
    30     Sachin     Gupta
    40     Peter     Gabriel
    then the query should return
    10     Amit     Kumar
    20     Kishore     Kumar
    id, name,L_name being the 3 columns in table
    Apprecite you help.
    Thank you
    Mary

    SQL> create table mytable (id,name,l_name)
      2  as
      3  select 10, 'Amit', 'Kumar' from dual union all
      4  select 20, 'Kishore', 'Kumar' from dual union all
      5  select 30, 'Sachin', 'Gupta' from dual union all
      6  select 40, 'Peter', 'Gabriel' from dual
      7  /
    Table created.
    SQL> select id
      2       , name
      3       , l_name
      4    from ( select t.*
      5                , count(*) over (partition by l_name) cnt
      6             from mytable t
      7         )
      8   where cnt > 1
      9  /
                                        ID NAME    L_NAME
                                        10 Amit    Kumar
                                        20 Kishore Kumar
    2 rows selected.Regards,
    Rob.

  • BDC steps differ when inputing same record with different other field value

    CODEDATE--
    ETC...(there is of course other field)
    11----01.10.2007   (do process A C D)
    12----01.10.2007   (do process A C D)
    12----01.11.2007   (Having same code field so do process A B C D)
    13----01.11.2007   (do process A C D)
    14----01.10.2007   (do process A C D)
    15----01.11.2007   (do process A C D)
    15----01.12.2007   (Having same code field so do process A B C D)
    16----01.10.2007   (do process A C D)
    hi i am doing a BDC batch my input table a bit like above.
    first record will do process A C D
    second record will do process A C D
    thirt record will do process A B C D
    second record will do process A C D
    Any hint of how i can do that plzzzz .  Urgent helppp needed

    as per understanding,
    if code = 11 and date = 01.10.2007 then u need process A C and D  right.
    define 4 subrountine with A B C D logics.
    define one more subroutine with SR1 and SR2.
    inside SR1 call 3 subroutines A C D
    and SR2 call A B C D.
    if code = 11 and date = 01.10.2007 then
    call subroutine SR1,
    if if code = 12 and date = 01.11.2007 then call Subroutine SR2.
    if u have any issue, let me know the detailed requirement.

  • Macro/VBA script to merge rows with same values in another column

    Hi.
    I'm developing a dance competition application, using Excel 2010, and have so far managed to put judges' marked scores into a worksheet through a userform.
    Now I would like to make the worksheet more presentable as a scoreboard, as you would manually, but via VBA scripts.
    Exhibit Numbers (Column G) are unique identifiers (per competition) for contestants and each contestant is typically judged by three judges.  The scores in three separate categories from one judge would spread in one row so each contestant would have three
    rows.
    I would like to merge rows of columns where the totals from the judges go (Columns P to U) for each contestant.
    I've considered using some kind of loop but I don't have enough experience in vba scripting, it gets overcomplicated. Could someone please help?
    Many thanks.
    Maki Koyama (Canberra, AUS)

    Hi,
    You cannot add a static "Y" inside a when looping over "i". You need to ensure that "Y" changes along with X. Try the modified code below.
    List elements = new ArrayList();
    for (int i=0; i<XXX; i++) {
    IZZZ.IVisibilityElement el = wdContext.createVisibilityElement();
    el.setVisAttr(i); // Change Y to i
    elements.add(el);
    wdContext.nodeVisibility().bind(elements);
    That should give you an idea of what is erroneous in the code.
    Thanks.
    HTH.
    p256960

  • Best logic to insert records with constant set of values.

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production).
    i have process type 'I' and 'E'.
    if process type = 'I' then i have to insert five records into table.
    "company,job type,serial,process type,value,created by,created on"
    here all columns will be having same value except value column what i have mentioned.
    that means for
    first record the valuecolumn = 'emp code',
    second record value = 'con no',
    third record value = 'weight',
    fourth record value = 'volume'
    fifth record value = 'pack type'
    Right now i am planning to do like
    k= 5--if process = 'I' else k = 6.
    n := 0;
    for 1..n loop
    n := n + 1;
    exit when n = k;
    if n = 1 then
    insert with value = 'emp code'
    elsif n = 2 then
    value = 'con no'
    end if;
    end loop
    n  := 0;
    k := 0;Is this is the best way or i do we have any better logic to do this?
    Please advise.
    Thanks..
    Edited by: GD on Sep 17, 2011 8:59 PM

    I have successfully inserted seven records in one form submit operation by looping through the command object execute method.
    However, the data that is being inserted by the command object is repetition of the first record and the command object is not taking any data from the text boxes for the second record onwards. In this I had used the isert record behavious generated by DW CS4 and modified it to suit my requirement. However, the data inserted in the first row is getting repeated in all the seven rows.
    Please help.
    Also advise if there are any free dreamweaver server side validation extensions available.

  • How to resolve error with DateField being Null value

    Hello,
    I have been playing with Flex on and off for a while now. I'm
    getting the hand of it more, but it's simple problems I can't
    resolve!
    I have a DateField which is loaded from a mysql Database, it
    all works fine. My problem is when creating a new record in my
    database (so my array primary key is set to 0)
    here is my datagrid:
    Code:
    <mx:DateField id = "orderdate" formatString="YYYY-MM-DD"
    width="170" showToday="true" text ="{currentOrder.date}"/>
    and here is my error on line 446 of DateField.as:
    Code:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at
    mx.controls::DateField$/stringToDate()[E:\dev\3.1.0\frameworks\projects\framework\src\mx\ controls\DateField.as:446]
    at
    mx.controls::DateField/displayDropdown()[E:\dev\3.1.0\frameworks\projects\framework\src\m x\controls\DateField.as:2118]
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at
    mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.1.0\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8565]
    at
    mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.1.0\frameworks\projects\framework\src \mx\core\UIComponent.as:8508]
    Perhaps I add a check if the array value is null and if so
    make it todays date? How can i do this?

    hi there, Thanks a lot for your response
    I tried your code as the code i have attached. it gives me
    the warning i need quote marks
    Open quote is expected for attribute "text". adman2/src/forms
    OrderForm.mxml
    but if i add quotations, then the datefield text appears as
    the code!

Maybe you are looking for

  • Error When Deleting From A Trigger

    When I use a trigger to delete from my Oracle Spatial table, the triggering delete statement will fail if the Oracle Spatial table has a spatial index. Details: Tables CHEV_WELLBORE and CHEV_WELLBORE_SDO need to stay in sync. CHEV_WELLBORE_SDO has an

  • HP Officejet 4315 with Windows 7 - How to scan into a .pdf file?

    My Officejet under HP Solutions software worked wonderful at scanning files into .pdf with Windows Vista.  Now that I have an upgraded computer with Windows 7, I've found that HP Solution is no longer available and I have to use the Windows Scan and

  • How to safely remove version of firefox that uses the system default locale?

    I have Firefox with Greek locale due to my location. I want to use Firefox in English, so I downloaded the English version and installed (in another HDD). I've already set it as a default browser, and thus, clicking at the firefox quick launch icon o

  • Mac and Acrobat 9 prof. e-mail

    Please excuse my bad english! I use snow leopard and Acrobat 9 prof. my e-mail rogram ist thunderbird-latest version . Whenever I try to send a pdf-document by mail or i want to create my own it appears the following: SendMail kann nicht mit Ihrem St

  • Why is Logic crashing upon quitting (have to Force Quit)?

    Logic is crashing whenever I quit. Logic prompts me to save the session like normal and then "flashes" before freezing and necessitating me to Force Quit. This just started happening a few weeks ago. Thanks