Query to map values between tables

Hi,
I'm trying to group data from the following three tables to create a new table.
Fields in bmf: account_no, trans_date
cmf: account_no, balance_due
acct_map: account_no, external_id
The fields I want in my new table are : external_id, account_no, balance_due.
When I use query 1, without the external_id column, it works fine and populates the data correctly. But when i try query 2, it creates a blank table. Will be great if anyone can point out my mistake and correct my query.
Many thanks!
novice.
Query 1:
create table paid as
select bmf.account_no, sum(cmf.balance_due) postpaid_balance
from bmf, cmf
where to_char(bmf.trans_date, 'YYYY MM DD') = '1996 08 14' and
bmf.account_no = cmf.account_no
group by bmf.account_no
Query 2:
create table paid as
select bmf.account_no, sum(cmf.balance_due) postpaid_balance, acct_map.external_id
from bmf, cmf, acct_map
where to_char(bmf.trans_date, 'YYYY MM DD') = '1996 08 14' and
bmf.account_no = cmf.account_no and
acct_map.account_no = bmf.account_no
group by bmf.account_no, acct_map.external_id

Sorry, perhaps i should have been more clear.
create table accounts (column1 number, .... etc);
insert into accounts () values (......);This allows users to see what your queries return, right now we have NO idea what your data looks like.
Also, expected output of your queries...you saying "it doesn't do what i want" doesn't help us much when we don't know what you want (this is where, using the sample data you provide to us, you show us what the result should be).
I'm not saying by any means you HAVE to do this, i'm just telling you that it's much more likely you'll get the help you are looking for if you do, that's all.
Try to put yourself in our shoes, being asked a question with no context, near no information and nothing to go on. Would you jump at the chance to guess and fumble around, or would you ask more questions to save time in the end?

Similar Messages

  • How to map values between Contract and Purchase Order...

    Hi friends,
                        We are using SRM 5.0 (ECS). I am facing a problem with Purchase Order.
    . I am creating Contract locally through Live Auction. After that I am creating Purchase Order through Live Auction. So in Purchase Order Quantity, Net Price, Gross Price, and Long Text etc. not coming which is defined in Contract.  PO capturing the values from Live Auction, means no relation between the Contract and Purchase Order. After making Contract again I have to changes in the Purchase Order.
                So how to map the values from Contract to PO in SRM?  I want to map between contract and Purchase Order like R/3. At the time of creation of PO ( in R/3 )  we can adopt the Contract so all the relevant values comes from Contract to PO. In SRM how will I do?
    Please suggest me.

    When you create PO and a contract from a Live Auciton, they will not be mapped.
    While creating a PO (BBP_POC - Process Purchase Order); in the PO line item assign the contract and item reference. Only then they will be linked.
    Hope this helps.
    Regards
    Kathirvel

  • Qualified query on map values

    Hi,
    I would like to do something like the following in JDOQL:
    map["key"].attribute == "bla"
    The candidate class has a map "_map", using a String as key and a PC (at
    its best of unknown type) as value. This PC has an attribute "_attribute".
    So I would like to perform queries on the value objects which are
    qualified by a certain key. I don't think this is possible with standard
    JDOQL, is it? What about a query extension, e.g.
    map.ext:qualify("key").attribute == "bla"
    Is this feasible?
    Cheers,
    Andreas

    You're right that this is not possible under standard JDOQL, and Kodo
    currently doesn't have any support for it. In fact, we have it logged
    as a bug, because we think it's a feature that we should support, even
    if it is not in the JDO spec:
    http://bugzilla.solarmetric.com/show_bug.cgi?id=539
    Yes, you can probably implement this with a query extension:
    "_map.ext:get(key) == value"
    The closest sample we have is the source for the
    kodo/jdbc/query/GetColumn.java extension included in your Kodo
    distribution. Instead of using getClassMapping(), you should use
    getFieldMapping(), and cast the field mapping to a
    kodo.jdbc.meta.AbstractMapFieldMapping. That should allow you to get
    the value column.

  • Mapping or relation between tables

    Hello
    I have a application, that I installed on top of Oracle 11G. this database has more than 200 tables all linked based on keys. Sorry my terminology may not be so good since am not a dba.
    I would like to study the relationships between tables to better understand the application.
    Is there a tool that allows me to view the relationship between the tables or provides me a mapping between the tables, very similar to UML mapping that shows relationships between classes.
    Thanks;

    column contacts.contact should only contain values which exist in persons.id or companys.id.
    if i put two foreign key constraints on table contacts witch reference persons.id and companys.id i get a error when inserting any value into contacts.
    example:
    table persons:
    id | name
    99 | john
    insert into contacts
    values(1,2,99);
    here i get the error.
    i think its because the second fk-constraint does not accept this value.

  • Parse comma separated value and map with other table to get Name and change it back to comma separate.

    Hi,
    I have one existing view(with around 15 fields), in which I have to add few more fields from table called PI.
    Now these fields have values like (55C4444F-D83B-4F96-A011-367A3755BA6C , F52388E2-485B-49DF-8534-FDF46D23F59E , 722432E1-F063-4CBD-B83D-1B97836E82953) 3 values comma separated.(Sometimes only one value and sometimes 4 or 5 or 7-8 depend on user has entered
    on web page)
    Also I have another table called PHA and this tables has 2 fields Values and Name so I have to map this two tables based on VALUES fields and get Name from this PHA table and show in view and that also Comma separated.
    So basically I have to Parse the PI table's Values field 1st, map it with PHA table to get Name and then Make it comma separated in that existing view.
    To make fields comma separate I used below query,
    (SELECT DISTINCT SUBSTRING
                SELECT ','+ PI.[Name]  AS [text()]
                FROM [DB].[dbo].[Table] PHA1
    Inner Join  [DB].[dbo].[Table] PI
    ON PHA.[Value] = PI.[VALUE]
                WHERE PHA1.PId =PHA2.PId and PHA1.CId = PHA2.CId
                ORDER BY PHA1.PId
                For XML PATH ('')
            ), 2, 1000) 
    FROM [DB].[dbo].[Table] PHA2
    Inner Join [cSharpSite_profiles].[dbo].[PetAllergies] PA
    Inner Join  [DB].[dbo].[Table] PI
    ON PHA.[Value] = PI.[VALUE]
    ) [Name]
    Vicky

    Wait, this sounds wrong. You have a view where you group values into a comma-separated list. While that surely will make some purists cringe, I can see that it makes sense from a presentation perspective.
    But if you want to use these concatenated values as atomic values again, you should go back to the base tables and them from there. Building views on views may sometimes be a good idea, but if you are too keen on reuse you can cause a performance disaster.
    So do it right from the beginning.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to build a query to join on two tables without mapping

    I did Automatic mapping by the workbench Directofield mapping with the table and java object.
    Wanted to build a simple join query by joining on the same field on both the tables.Not the sql query through the toplink using expression builder.
    Please help.............
    Spent one full day for this................

    Thanks Don for the reply,sorry to bug you,but i need help.....
    SELECT A.AGNCY_C,
         A.TYPE_C,
         A.RESN_C,
         A.S_TYPE_C,
         A.SUB_ID_C,
         A.RY_C
    FROM RATING A, REF B
    WHERE A.ID_C = B._ID_C
    AND A.ALPHA_C = B.ALPHA_C
    AND A.EFF_D >= B.MATURITY_D
    This is the real query i was talking about.I did mapping automatically through the workbench,generated java classes also throught the workbench.
    Now they don't want to execute the raw sql.They wanted to get all the RATING objects with the where condition.
    So how to build a query by using toplink.
    tried your example
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression creditRating = builder.getTable("RATING").getField("ID_C");
    Expression issue_ref = builder.getTable("REF").getField("ID_C");
    Expression join = creditRating.equal(issue_ref);
    I am getting java.lang.OutOfMemoryError
    error.
    I selected the option generate classes and descriptors
    from the tables (RATING,REF).,so it created the classes and dscriptors automatically.
    In Database script for the table RATING like this
    ALTER TABLE RATING ADD (
    CONSTRAINT RATING_F1 FOREIGN KEY (ID_C, ALPHA_C)
    REFERENCES REF (ID_C,ALPHA_C));
    I think when i generate descriptor automatically it is keeping this association.
    Please help me.........

  • Caching values between different executions of a message mapping

    Hi all
    Like global container object is used for caching values between different user defined functions
    within the same message mapping.
    Can v have some sort of cachingvalues
    between simultaneos exceutions of same message mapping?
    Thanks and Regards
    Bhasker

    Hi Bhasker raj,
        This facility is there if you are using seeburger adapters.
    YOu can use something called seeburger variables which can hold the data beyong the mapping in some permanent memory.
    Alternatively, you can think of creating a ZTABLE in the ABAP stack of XI and storing the data you want in it, using a UDF and get it back in another UDF.
    YOu can use the first UDF at last node/field in the message mapping and the
    secomd UDF in the first node/field in the mapping.
    Regards,
    Ravi

  • How to achieve transport of value mapping replication cache table values ?

    During the migration of our interface from XI3.0 to PI 7.11,
    I need to transport the value mapping replication cache table values present in cache monitoring of runtime workbench in
    XI 3.0 PRD  to PI 7.11 DEV .
    Please let me know the ways to acheive this so that I can have the same values present in PI 7.11 Value Mapping Cache table as maintained in XI 3.0.
    Please point me into correct direction.
    Regards
    PS

    Click on "Tools" option, select "Export Configuration Objects" -> "Individual Objects" -> Choose the "Value Mapping Group" type, and then select the value mappings you want to transport.

  • UKMS versus Value Mapping versus Z tables ?

    Hello,
    has someone already made a choice whether to use UKMS or Value Mapping or Z Tables to do mapping or filtering of data ?
    If yes, what were the reasons to go for one or the other solution ?
    - both UKMS / Value Mapping provide key-pair mappings
    - UKMS can be called via RFC or out of XSLT. (Out of User-Defined function I am not sure)
    - Value Mapping can at least be called out of graphical mapping
    - the UKMS / Value Mapping approach looks very similar to me.
    - Z Tables might be more flexibel in defining the structure required
    - is there a caching advantage in one of these solutions ?
    many thx in advance
    Uwe

    Hi Uwe Knöfel ,
    has someone already made a choice whether to use UKMS or Value Mapping or Z Tables to do mapping or filtering of data ?
    Usually YES, XI Architect will decide what to follow..
    If yes, what were the reasons to go for one or the other solution ?
    Mostly it depends upon Complexity,Kind and Volume of data.Suppose there is less volume of data and simple processing is needed we may go for Value mapping than Ztables.
    + is there a caching advantage in one of these solutions ?+
    May not..
    Regards,
    Ramesh

  • Mapping between tables or table to dimension OWB 11G

    Hi,
    I want to know the difference between mapping to a dimension and mapping to a table.
    My company already has mappings created...
    They map from a table to a dimension. Not as a SCD.
    When I run the mapping it only updates the target dimension table, no new rows are added.
    I see when I create a mapping between to tables, I can choose loading type.
    I was wonder why you would load to a dimension if only updates rows. How can I load to a dimension and have my inserts running as well.
    Thank you for any help offered

    The loading type on a table can insert/update/merge/delete - it's up to you what you do, what happens in a load is dependent on the loading type and the data (if there is no new data, then no new rows will be added). The dimension operator has loading behavior consistent with type 1,2,3 SCDs - in the end it boils down to insert/update/merge also.
    Cheers
    David

  • 1.1 query builder join between tables

    In the latest Sql Developer.
    I invoke the query builder and select multiple tables that have foreign keys between them. These foreign key relationships appear in the diagram (good job).
    How do I make those relationship appear in the SQL that query builder returns to the sql worksheet. I shouldn't have to re-specify them on the where/criteria tab.
    It would be nice if these relationships are defaulted in the joining of tables.

    I overlayed the pre-release versionsDo you mean you installed in the same directory?
    Don't do that.
    There's a system directory (sqldeveloper\sqldeveloper\system) which holds settings and everything, which very well might be corrupted to be used for a newer release.
    Try deleting it, it will be regenerated at next startup. Or even better: re-install in another directory all together...
    K.

  • Inserting field text into sql query and comparing values to another table

    I have an issue in Visual Web Developer 2010 that I need help with.
    The code below is a Gridview Sql query where I'm extracting PART_NUMBER from various tables.  I would like to add the table name in a separate field named Table.  The end result should appear as follows:
    PART_NUMBER     Table
    010-0075-06       Resistors (or Capacitors, etc.)
    Sql query:
    SELECT     PART_NUMBER
    FROM         Capacitors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Connectors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Diodes
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         ICs
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Inductors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Misc
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Relays
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Resistors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Switches
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Transformers
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Transistors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         [Crystals and Oscillators]
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    ORDER BY PART_NUMBER
    I have a separate table (CIS Manufacturer Parts) that contains manufacturer data for the above parts.  Multiple manufacturer rows can exist.  The connection between tables in the PART_NUMBER field.  What I would like to do is make this query
    add the table name to the gridview output listing only parts without manufacturer data and the table they can be found in.
    This is a lot for a newbie so I will appreciate any help, thanks!

    Hello Bulldog248,
    Thank you for your post.
    Your issue is out of support range of VS General Question forum which mainly discusses the usage issue of Visual Studio IDE such as
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Query to find all relationships between tables

    Please help me wit the following
    Query to find all relationships between tables
    SAMPLE OUTPUT:
    PRIMTAB PRIMCOL FOREIGNTAB FOREIGN KEY
    DEPT DEPTNO EMP DEPTNO
    Return all records in the database.
    PLEASE HELP

    SET LINESIZE 150
    COLUMN primcol FORMAT A30
    COLUMN foreigncol FORMAT A30
    SELECT uc1.table_name AS primtab,
    ucc1.column_name AS primcol,
    uc2.table_name AS foreigntab,
    ucc2.column_name AS foreigncol
    FROM user_constraints uc1,
    user_constraints uc2,
    user_cons_columns ucc1,
    user_cons_columns ucc2
    WHERE uc1.constraint_name = uc2.r_constraint_name
    AND uc1.constraint_name = ucc1.constraint_name
    AND uc2.constraint_name = ucc2.constraint_name
    AND ucc1.position = ucc2.position
    ORDER BY uc1.table_name,
    ucc1.position
    /

  • Query on differences between table Icons and types in smartforms

    Hello,
    I have a question regarding the apparent differences between tables in smartforms.
    I have noticed on some of the default smartforms that are supplied the table icon is the same as on the
    'Create new session' button at the top of a Sap session window. The icon on a table that I am currently working on is like a 'spread sheet' design, a heading with columns, as shown in the current documentation. The way the  two styles of tables work is different.
    Is the difference down to the fact one was created in an older implementation of Sap?
    The reason I ask is because the table I refered to initially, is easier when configuring cells.
    Regards
    Mike.

    Hello Karthik
    Thanks for taking the time to reply to my question.
    The difference in the icons but with essentially the same function has always confused me since starting Smartforms.
    Thank you for enlightening me.
    I asked the question because the Complex node has a feature that I could have used. I have managed though to solve my problem using a table node.
    Ten points awarded.
    Best Regards
    Mike Spear.

  • How to combine large number of key-value pair tables into a single table?

    I have 250+ key-value pair tables with the following characteristics
    1) keys are unique within a table but may or may not be unique across tables
    2) each table has about 2 million rows
    What is the best way to create a single table with all the unique key-values from all these tables? The following two queries work till about 150+ tables
    with
      t1 as ( select 1 as key, 'a1' as val from dual union all
              select 2 as key, 'a1' as val from dual union all
              select 3 as key, 'a2' as val from dual )
    , t2 as ( select 2 as key, 'b1' as val from dual union all
              select 3 as key, 'b2' as val from dual union all
              select 4 as key, 'b3' as val from dual )
    , t3 as ( select 1 as key, 'c1' as val from dual union all
              select 3 as key, 'c1' as val from dual union all
              select 5 as key, 'c2' as val from dual )
    select coalesce(t1.key, t2.key, t3.key) as key
    ,      max(t1.val) as val1
    ,      max(t2.val) as val2
    ,      max(t3.val) as val3
    from t1
    full join t2 on ( t1.key = t2.key )
    full join t3 on ( t2.key = t3.key )
    group by coalesce(t1.key, t2.key, t3.key)
    with
      master as ( select rownum as key from dual connect by level <= 5 )
    , t1 as ( select 1 as key, 'a1' as val from dual union all
              select 2 as key, 'a1' as val from dual union all
              select 3 as key, 'a2' as val from dual )
    , t2 as ( select 2 as key, 'b1' as val from dual union all
              select 3 as key, 'b2' as val from dual union all
              select 4 as key, 'b3' as val from dual )
    , t3 as ( select 1 as key, 'c1' as val from dual union all
              select 3 as key, 'c1' as val from dual union all
              select 5 as key, 'c2' as val from dual )
    select m.key as key
    ,      t1.val as val1
    ,      t2.val as val2
    ,      t3.val as val3
    from master m
    left join t1 on ( t1.key = m.key )
    left join t2 on ( t2.key = m.key )
    left join t3 on ( t3.key = m.key )
    /

    A couple of questions, then a possible solution.
    Why on earth do you have 250+ key-value pair tables?
    Why on earth do you want to consolodate them into one table with one row per key?
    You could do a pivot of all of the tables, without joining. something like:
    with
      t1 as ( select 1 as key, 'a1' as val from dual union all
              select 2 as key, 'a1' as val from dual union all
              select 3 as key, 'a2' as val from dual )
    , t2 as ( select 2 as key, 'b1' as val from dual union all
              select 3 as key, 'b2' as val from dual union all
              select 4 as key, 'b3' as val from dual )
    , t3 as ( select 1 as key, 'c1' as val from dual union all
              select 3 as key, 'c1' as val from dual union all
              select 5 as key, 'c2' as val from dual )
    select key, max(t1val), max(t2val), max(t3val)
    FROM (select key, val t1val, null t2val, null t3val
          from t1
          union all
          select key, null, val, null
          from t2
          union all
          select key, null, null, val
          from t3)
    group by keyIf you can do this in a single query, unioning all 250+ tables, then you do not need to worry about chaining or migration. It might be necessary to do it in a couple of passes, depending on the resources available on your server. If so, I would be inclined to create the table first, with a larger than normal percent free, then do the first set as a straight insert, and the remaining pass or passes as a merge.
    Another alternative might be to use the approach above, but limit the range of keys in each pass. So pass one would have a predicate like where key between 1 and 10 in each branch of the union, pass 2 would have key between 11 and 20 etc. That way everything would be straight inserts.
    Having said all that, I go back to my second question above, why on earth do you want/need to do this? What is the business requirement you are trying to solve. There might be a much better way to meet the requirement.
    John

Maybe you are looking for