Merge 2 tables based on key and dates - complex

in powerquery - given 2 tables, both with a startdate and a key, how to merge them to get a table that includes a row for each valid key/startdate combination? (Table3 below is my desired result):
Table1.Key
Table1.Durablekey
Table1.startdate
Table1.color
Table1.type
Table.location
1A
1D
1/1/2012
Red
T1
Boston
2A
1D
7/1/2012
Red
T1
NY
3A
1D
1/1/2013
Blue
T1
LA
4A
2D
1/1/2012
Yellow
T2
Boston
Table2.Key
Table2.Durablekey
Table2.startdate
Table2.quality
1B
1D
2/1/2012
Great
2B
1D
3/1/2012
Good
3B
1D
7/1/2012
Poor
4B
1D
2/1/2013
Excellent
5B
2D
1/1/2012
Good
Table 3
Table1.Key
Table2.Key
START DATE
TAble1.color
Table1.type
Table.location
Table2.quality
1A
NA
1/1/2012
Red
T1
Boston
NA
1A
1B
2/1/2012
Red
T1
Boston
Great
1A
2B
3/1/2012
Red
T1
Boston
Good
2A
3B
7/1/2012
Blue
T1
NY
Poor
3A
3B
1/1/2013
Blue
T1
LA
Poor
3A
4B
1/1/2013
Blue
T1
LA
Excellent
4A
5B
1/1/2012
Yellow
T2
Boston
Good

Have you tried using "Merge Queries" and selecting the key and start date columns in each table?
Ehren

Similar Messages

  • FM / BAPI to update STEUC field in marc Table basing on material and plant

    Hi,
    I need to to update STEUC field in marc Table basing on material and plant. please suggest FM / BAPI.
    Thanks.
    raviraj.

    Hi
    Try this BAPI function module:
    " BAPI_MATERIAL_MAINTAINDATA_RT "
    Data: LS_HEADDATA TYPE BAPIE1MATHEAD,
             LS_RETURN TYPE BAPIRETURN1,
              LT_PLANT TYPE TABLE OF BAPIE1MARCRT,          LS_PLANT TYPE BAPIE1MARCRT,
              LS_PLANTX TYPE BAPIE1MARCRTX,          LT_PLANTX TYPE TABLE OF BAPIE1MARCRTX.
            CALL FUNCTION 'BAPI_MATERIAL_MAINTAINDATA_RT'
                   EXPORTING
                       HEADDATA   = LS_HEADDATA
                   IMPORTING
                       RETURN     = LS_RETURN
                   TABLES
                       PLANTDATA  = LT_PLANT
                       PLANTDATAX = LT_PLANTX.
    Check the PLANTDATA in the above fm in which pass your ''STEUC'' to BAPIE1MARCRT-CTRL_CODE......
    Hope this works.....

  • How to create a new table based out of old data rows

    Hi All,
    How to create a new table based out of old data rows. Also how can we find out the DBF for different users in a database?
    Saqib

    Not very clear what you need. I'll try to interpret...
    How to create a new table based out of old data rowsIf this means how to create a table from an existing one, then you can do :
    SQL> create table <new table> as select * from <old table>;
    if you need a subset of rows you can add a where clause.
    how can we find out the DBF for different users in a database?Here I need some more clarification. What do you mean exactly ?

  • Deletion of bookmarks from RSWR_DATA table based on 'Last access' date

    We want to delete the 7.X bookmarks from RSWR_DATA table based on ‘Last accessed’ date. The program RSWR_BOOKMARK_REORG does not provide the selection criteria to delete the bookmarks based on last accessed date.
    Is there any alternative program that deletes bookmarks from RSWR_DATA table based on last accessed date?
    Please advice.

    We want to delete the 7.X bookmarks from RSWR_DATA table based on ‘Last accessed’ date. The program RSWR_BOOKMARK_REORG does not provide the selection criteria to delete the bookmarks based on last accessed date.
    Is there any alternative program that deletes bookmarks from RSWR_DATA table based on last accessed date?
    Please advice.

  • C# Wrapper for Berkeley Db is not ptting proper key and data values

    Hi All,
    I am using C# wrapper for Berkeley Db which is available at sourceforge.net.
    Now when i am putting an integer as key value, it returns keysize as 9,
    instead of returning 4.
    That C# Wrapper contains a serialzing class called BDBFormatter which pass all the data into DBT .
    The file created using C# Wrapper is not read as key and data values are not coming properly if i try to read the file using only C berkeley db.
    Can anybody suggest me some way to create a berkeley Db file in C#. which can be accessible by Linux C berkeley Db APIs.
    Any help will be appreciated.....
    Thanks,
    Eric Hass

    user11218092 wrote:
    Hi All,
    I am using C# wrapper for Berkeley Db which is available at sourceforge.net.
    Now when i am putting an integer as key value, it returns keysize as 9,
    instead of returning 4.
    That C# Wrapper contains a serialzing class called BDBFormatter which pass all the data into DBT .
    The file created using C# Wrapper is not read as key and data values are not coming properly if i try to read the file using only C berkeley db.
    How data is encoded is up to the programmer. There is no defined way in BDB to do that, it is application dependent.
    The BDBFormatter class is just one way of encoding C# classes and structs (which includes the ability to serialize Nulls).
    It is written with BDB in mind and has some performance advantages over the standard .NET serialization classes.
    If you want to read back the data from code written in another language, you will have to duplicate how data is encoded/decoded.
    The source code is there to read. ;-)
    Karl

  • Binding for table produces list for other tables using foreign key and crea

    Using
    software Jdev 11G, WLS 11G, Oracle DB 11G, Windows Vista platform
    technology EJB 3.0, jspx, backing beans, session bean
    I cannot create a namedquery on my secondary table. The method for the column uses the entity object rather than the name and value of the column.
    For instance,
    (Coketruck) table has inventory records(Products) table
    Coketruck has one to many to the Products table
    Products has a many to one to the Coketruck
    I need to return the products from the product table based on the CokeTruck but I cannot create a namedQuery because the method in the Product table is an entity object type instead of a long that I can use to look up all the products based off the column truck_id.
    This is what I was expecting…
    Private Long truckId;
    public Long getTruckId() {
    return truckId;
    public void setTruckId (Long truckId) {
    this. truckId = truckId;
    Instead this is what I have…
    @ManyToOne
    @JoinColumn(name = "TRUCK_ID")
    private Coketruck coketruck;
    this. coketruck = coketruck
    public Coketruck getCoketruck() {
    return coketruck;
    public void set Coketruck (Coketruck coketruck) {
    this. coketruck = coketruck;
    How do I do a query on the Product table to return all the products that are in the coketruck?
    If I do the following it expects for me to pass the Entity Object which I cannot use as search criteria for my find method.
    @NamedQuery(name = "Products.findById", query = "select o from Products o where o.truckId = :truckId")
    On a different note but the same song…
    I noticed that when I look at my Session Bean Data Contols that the coketruck already has a list of the products. I have created a jsp page with a backing bean and have been able to use the namedquery on the coketruck entity to retrieve the productList. Unfortunately I need to sort the products by type and was also not able to find where to perform the work to be able to iterate through the productList to get my desired display. Therefore I started looking at doing another namedquery that would only retrieve the product_type ordering by the truckId.
    Seems I have come full circle… I don’t care what method I have to use to get the info back.
    Any help is greatly appreciated!

    user9005175 wrote:
    Hi!
    I work on an application wich uses a shopping cart stored in a database. The shopping cart uses two tables:
    CART: Holds information common for one shopping cart: the user it is connected to etc.
    - Primary key: CART_ID
    CART_ROW: One row in the cart, e.g. one new product to buy.
    - Primary key: ROW_ID
    - Foreign key: CART_ROW.CART_ID references CART.CART_ID
    From the code the rows in the cart are collected per cart, as is modelled by the foreign key. There exists one more relationship, which we use in the code, but which is not modelled by a foreign key in the database. One row can be dependent on another row, which makes the other row a parent.
    CART_ROW has a column PARENT_ID which references CART_ROW.ROW_ID.
    Should we add a foreign key for PARENT_ID? Or are there any questions to consider when it is a foreign key to the same table?
    I suggest to add foreign key it wont harm the performance (except while on insert when there would be validation for the foreign key). But it would prevent users to insert wrong/corrupt data either through code or directly by loggin in the database.
    A while ago we added indexes, both on ROW_ID and on PARENT_ID. Could the index on PARENT_ID have been harmful, since there is no foreign key?
    Index on parent_id would only be harmful if you do not make use of index after creating it (i.e. there is no query which make use of this index).
    And if you decide to have a foreign key on parent_id then I suggest to have index too on parent_id as it would be helpful atleast when you delete any record in this table.
    Best regards!

  • Creating a table based on Category and Sub-Categories

    Hi
    I am building an extensive home budget. I have 3 tables showing, monthly, quarterly and annual costs. These tables contain Categories and Sub-Categories. I have created a table and chart to show the percentage of the total costs for each Category. For the two Categories with the largest percentage of the total cost I would like to create a table (and chart, no problem, based on my first template) showing the breakdown of the Sub-Categories. However this information is to be retrieved from 3 tables, and I was hoping to create the table automatically. If not I must individually go to each different table and find the relevant Sub-Category and manually input the text and link the cell for the value to my new table. This gives room for error in my opinion and is a nuisance as my budget file now contains about 8 sheets so even on 27" iMac requires a considerable amount of scrolling around.
    Am I expecting too much of Numbers or missing something totally? I do not have much experience of spreadsheets, just basic tables and calculations in Excel before coming over from the Dark Side!
    Many thanks for any advice
    Shirley

    Hi Barry
    Many thanks for your reply and apologies for my delay in responding.
    Hope I am doing this photo embedding correctly via Flikr:
    Page 1
    I apologise also for my incorrect terminology - please bear with me on this, unfortunately I never used Excel much so terminology is pretty much my own . I believe that I have one sheet, which then changes into different numbers of pages depending on the page size I set, so with these examples 4 pages. 14 tables and one chart at this time
    The tables on the second screenshot were the only way I could figure out how to retrieve the data for the final table and chart (% Total Monthly Expenses)
    Now what I want to do is for each (or in fact the three largest) budget categories is to give a breakdown of what in that category is, percentage wise, costing the most. Preferably, I want to get this breakdown category information automatically so that human error is ruled out (that I cannot overlook an entry in the any of the tables in my first example). Perhaps I am asking too much, but I thought it was worth asking!
    Again many thanks for responding and for your help with this
    regards
    Shirley

  • Join between Header & Detail tables based on age and group

    To find the age & group  amount in detail table based on  age & group_id in header ?
    Example: Let's take the seq_id =1 from header,it has age= 60 & group_id=23 (23 Months).
    In the detail table xx_detail,the age column represents the age of the person (0-65 represents the age in between 0 to 65 and so on).
    If the age is null,then that row indicates the group (0-12 represents the group in between 0 to 12 months ).If the age is not null,then the group1,group2,group3 have the amounts data.
    So Now i have to get the amount as 240(as my header seq_id=1,age=60,group_id=23 as it falls under 0-65 age & 13-59 group ).So i need a sql query to find the correct amount in detail based on header record. We have to pass the parameters age & group_id and get the amount from detail tables.Can anyone provide inputs how to achive this in the simplest way.
    SQL> select * from v$version  
      2  /  
    BANNER  
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production  
    PL/SQL Release 11.2.0.3.0 - Production  
    CORE    11.2.0.3.0      Production  
    TNS for Linux: Version 11.2.0.3.0 - Production  
    NLSRTL Version 11.2.0.3.0 - Production  
    SQL> desc xx_header;  
    Name                                      Null?    Type  
    SEQ_ID                                             VARCHAR2(6)  
    AGE                                                NUMBER  
    START_DATE                                         DATE 
    GROUP_ID                                           NUMBER  
    SQL> select * from xx_header;  
    SEQ_ID        AGE START_DATE   GROUP_ID  
    1               60      01-JAN-12            23  
    2               89      01-JAN-12            23  
    3               95      01-JAN-12            23  
    SQL> desc xx_detail;  
    Name                                       Null?    Type  
    SEQ_ID                                              VARCHAR2(10)  
    AGE                                                   VARCHAR2(10)  
    GROUP1                                             VARCHAR2(10)  
    GROUP2                                             VARCHAR2(10)  
    GROUP3                                             VARCHAR2(10)  
    SQL> select * from xx_detail;  
    SEQ_ID     AGE        GROUP1     GROUP2     GROUP3  
    1                                0-12              13-59       60-126  
    1           0-65               120                 240         300  
    1          66-135             100                 80          400

    Hi,
    Is this the same question that you asked 3 days ago
    https://forums.oracle.com/thread/2606197
    Whether it is or not, post the information requested in that message, which is also listed in the Forum FAQ:
    https://forums.oracle.com/message/9362002
    If it is the same question, don't post a new thread.  Mark this thread as "Answered" right away, and continue in the original thread.

  • How to get rid of extra data in character buffers for key and data

    Hi -
    Using the C API, I am using a cursor to just pull all the key/value pairs from a database.
    Here is the relevant code:
    /* Initialize key/data structures. */
    memset(&key, 0, sizeof(key));
    memset(&data, 0, sizeof(data));
    key.flags = DB_DBT_MALLOC;
    data.flags = DB_DBT_MALLOC;
    if((ret = dbp->cursor(dbp, NULL, &cursor, 0)) != 0) {
    dbp->err(dbp, ret, "%s", DATABASE);
    goto err;
    while((ret = cursor->c_get(cursor, &key, &data, DB_NEXT)) == 0) {
    fprintf(cgiOut, "%s|||%s\n", (char *)key.data, (char *)data.data);
    free(key.data);
    free(data.data);
    if(ret != DB_NOTFOUND) {
    dbp->err(dbp, ret, "cursor->c_get");
    goto err;
    This produces lines that in many cases contain extra characters at the ends, as though the malloced data was not being cleared before use. I wrote this routine originally in Java, and solved the problem there with the "setReuseBuffer(false)" Database Entry routine. Is there something similar in C?
    Garey Mills

    Sandra -
    I am using 4.5. I have solved the problem, however, by using the following code
    while((ret = cursor->c_get(cursor, &key, &data, DB_NEXT)) == 0) {
    char keyd, datad;
    keyd = (char *)key.data;
    datad = (char*)data.data;
    keyd[key.size] = '\0';
    datad[data.size] = '\0';
    So I am just using the size data returned to null terminate the strings in the buffers. Now everything works. Thanks for your response;
    Garey Mills

  • How to find out the table for Posting Key and A/R & A/P Document types

    hi folks,
    can you let me know which TABLE is used to Posting key and also which TABLE is used for Account Receivables and Account Payables.
    Thank you in advance.

    To find the table of posting key, select any posting key at OB41, then press F1, then click on hammer icon the table used will be displayed. For Posting Key TBSL is the table used.
    Posting Key TBSL
    Customer Master (General)  KNA1
    Customer Master (Company Code) KNB1
    Vendor Master (General) LFA1
    Vendor Master (Company Code) LFB1
    Satish
    (please close the thred if u satisfiy with the answer)

  • What is the difference between READ TABLE ITAB WITH KEY  and  TABLE KEY

    Hi Experts,
    what is the difference between
    READ TABLE <ITAB> WITH KEY <K1> = <C1>
                                                    <Kn> = <Cn> .
    and 
    READ TABLE <ITAB> WITH TABLE KEY <K1> = <C1>
                                                              <Kn> = <Cn> .
    Thanks
    Akash.

    Hi akashdeep,
    Nice question. I also tried to find out, but no much success. My opinion is that for practical purposes there is no difference.
    It may have difference in case of searching, especially sorted tables. (binary search or normal linear search).
    Case1: If our table is sorted table with defined key fields, and we give WITH TABLE KEY, then faster binary search is used.
    Case2 : If our table is sorted table with defined key fields, and we give WITH  KEY, (and no field contained in the keys), then normal linear search is used.
    regards,
    amit m.

  • Select from 2 tables with common key and than left join(unique result)

    Hi,
    I have 2 tables that have a common id (Customer_id) and I have a third table which contain her key consist of 3 column ( Customer_id , rms_customer_id,billind_tree_id) and have the manager_name field
    I am using a left join because not all the customers have a manager.
    I need to take only the manager_name field from the left join but the problem is that I am not getting a unique name results because the customer_id is not the primary key(only part of )
    so I have use the following :
    left join
    ( select * from ACCOUNT_Manager am where
    rms_customer_id <= all (select rms_customer_id from ACCOUNT_Manager am2 where
    am2.customer_id = am.customer_id )) am
    on c.ID = am.CUSTOMER_ID (C is one of the first 2 tables with the ID as key)
    Is there anyway more efficient of doing it ?
    Thanks

    Please consider the following when you post a question. This would help us help you better
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Which tables store the domains and data types?

    Hi.
    From what I know, DD01L stores all the domains (both SAP and user-created) in the system. Is this understanding correct?
    As for data types, which table stores them?
    Thanks.

    Hi,
    All abap program stored in the TADIR table and TRDIR
    Z_reports are stored in the table REPOSRC
    TVDIR is the system table(view) maintained by sap.
    in this all Tables are stored.
    TVDIR is a repository of VIEWS.
    The domains are stored in DD01L
    The tables that are created are stored in DD02L
    Fields are stored in DD03L.
    Data Elements are stored in DD04L
    DD06L                          Pool/cluster structures
    DD07L                          R/3 DD: values for the domains
    DD08L                          R/3 DD: relationship definitions
    DD09L                          DD: Technical settings of tables

  • How and when does Berkeley free the memory of key and data ?

    Hi,
    even though i just have posted a question several days ago, i couldnt find an answere to these questions in the Berkeley docs or on the internet:
    Does Berkleley Db free the data that is handeled to it with the key or the data objekt ?
    When is it free?
    How is the data managed that is in the secondary databases which points directly to the primary database and do i have to copy it?
    It would be great to have some answeres, because its hard to write something with low memory use, when you dont know how the memory is treated.

    Hi,
    Does Berkleley Db free the data that is handeled to it with the key or the data objekt ?Records in the berkeley db is stored as 'Key' & 'Data' pair. The data is accessed into / from the db using the 'Key'. The data in the db is freed when it is deleted.
    When is it free?The data in the db is freed after 'delete' followed by 'checkpoint' operation.
    How is the data managed that is in the secondary databases which points directly to the primary database and do i have to copy it?The secondary database is just another regular database whose 'Key' is what you choose it to be and the 'Data' is the key in the primary database. The primary and secondary databases are connected using the DB->associate() call. More info with example on this is available here : [http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am/second.html]
    Debsubhra Roy

  • Modelling tables in Transactional database and data warehouse

    Hello,
    Can any one please tell me what are the differences between modelling tables in a transactional databse compared with a data warehouse? And I want to know the process of multi dimensional modelling...

    Check here:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6ce7b0a4-0b01-0010-52ac-a6e813c35a84
    BI Data Modeling and Frontend Design [original link is broken]
    Regards,
    Luis

Maybe you are looking for

  • Clamshell Mode Prevents Waking from Sleep

    I've got a MacBook Pro (Intel, 2.33GHz) running 10.5. Since installing Leopard I've been bumping into periodic issues with trying to wake from sleep while in clamshell mode. (I've got a Samsung LCD monitor and a USB keyboard plugged into it, and most

  • Problem Digitally signing an xml document "Cannot resolve element"

    I am trying to sign a cXML document. I try to add 3 references to the XMLSignatureFactory but when it hits the 2nd on it throws an error "Cannot resolve element with ID cXMLData". How come I can't add more than 1? Here is the stack trace : java.lang.

  • My L key dose not work in normaL

    it onLy works when you press shift and L but it works on other user any ideas ?

  • Nobody knows the answer to this question...

    Alright, so yesterday I deauthorized all of my computers for itunes.  I copied all my music files from my previous computer and then copied them to the new computer.  All the work seemed to be done, however, I tried to play a particular song and it s

  • Internet via my N95 on a Mac

    Hi. I can still be surprised over the missing cooperation from Nokia, regarding Apple hardware. Considering that the OSX is so much better and faster than Vista and XP. Now that I got that issue of my chest. I've been trying to find out how to connec