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.

Similar Messages

  • Multiple 'logical joins' between a fact table and one dimension table

    It appears that one cannot create multiple ‘logical joins’ between a fact table and one dimension table in OBIEE using the Oracle BI Administration Tool. For example, considering a Business Model with a dimension table TIMES and a fact table FACT containing START_TIME and END_TIME, we would like to create separate logical joins from FACT to TIMES for the START_TIMEs and END_TIMEs? Obviously, the underlying foreign keys can be created, but as far as I can tell the Oracle BI Administration Tool doesn’t support this. The workaround would be to replicate the TIMES table, but that’s ugly.
    I seek an alternative approach.

    Try this. Create an two aliases for the TIMES dimension (Start & End) in the Physical Layer and then remove foreign key to the "Parent" Times dimension. Create the Foreign Key in the Physical Layer to the new aliases and then create the complex joins in the BMM Layer to the new aliases as well. This will allow you to present both dates within the same table in the Presentation Layer. Not the most elegant solution but it works.

  • Inner Join between two big tables

    Hi There,
    I have a situation where in which I have to write an inner join between two table of the order of (30k to 60 rows).
    My query is as simple as,
    select A.a,B.b from A ,B where A.a = B.b;
    N.B: a and b are of type varchar
    But the problem is it takes nearly 15 mins to run. Is there any better way of doing an inner join between such bigger tables?
    Thanks,
    Jose John.

    Thank you all for your help.....Indexing works....:)
    --JJ                                                                                                                                                                                                   

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

  • Can we apply join between two internal tables?

    Itab has fields A,B,C.
    Data: begin of itab occurs 1,
             A  type I,
             B type I,
             C type I,
             End of itab.
    Jtab has fields A, I, J.
    Data: begin of itab occurs 1,
             A  type I,
             I type I,
             J type I,
             End of itab
    The common field between itab and jtab is u201CAu201D.
    Now I need to collect A,B,C,I, J in another internal table ktab.
    How should I be doing this.
    If I use a SELECT query with inner join between itab and jtab it says u201Citab is not a database tableu201D.
    How should I get the result  ktab with A B C I J fields?
    Please help, nay help will be highly appreciated?

    a®s wrote:
    >
    > sort itab_all by A
    > delete adjacent duplicates from itab_all comparing A.
    >
    >
    Do you have the above code in ?
    Here A is common field between both tables, first we are appending itab_1 & itab_2 into table itab_all then deleting the adjacent duplicates from itab_all. then we are reading itab_1 & itab_2 for possible matches and update the same values in itab_all
    so there will NOT be a chance of duplicates in itab_all

  • How to bind the interactive form with a header/detail table.

    Hi there,
    I'm having problem to bind the adobe form with my detail table.
    When executing the layout after doing the binding, the detail fields in the form is repeating itself on all the rest of the rows for that column???

    Is the cardinality on the context correct?  Have you tried displaying this same context using a web dynpro table instead?

  • What is change header / detail tables

    hi
    could anybody tel me
    what is change header / detail tables

    hi Rich,
    these r from my test questions which were given in my institute where im learning abap.
    can u plz give the answers to these questions.
    regards,
    maqsood

  • 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

  • How to update a bc4j detail table based on master selection

    I have a bc4j table with single selection set.
    When I retrieve the index of the single selection and set the current row in my view object based on that index my detail view object does not update its record.
    Only when I am first populating my master view object does the detail view object update or if I set a small range and change between index ranges.
    I thought by changing the current row in the master view object the detail view object listener would handle cause the detail view to update.
    Please Help.

    This looks like a question better suited for the JDeveloper forum. I'd venture a guess that it's a problem with the setup of your associations.

  • Total column not changed between header & detailed screen

    I have a report with header data contains contracts information and detailed data contains orders, debit credit memo related to the contracts.  I write the report using CL_SALV_TABLE to display  contract value, usage  in full ALV_GRID. When I double click on a contract line, it will go to the second screen to show all orders related to that contract.  The second screen with orders information will be in a screen on a container with all standard function ( Export list to Excel, Word format etc..), sort, total and sub total) and a push button to go back to first screen.
      The report works fine but when I am on the second screen, I total and sub total the amount on that screen in order to check with total value in header record and it total up correctly by currency.
    But when I go back to the first screen, select a different contract record,  double click on the line to get to the order info screen,  all order data display correctly except that the total column still show amount from the previous detailed screen.  If I select the column again and click the total, it will total correctly.   I did refresh the data in the screen before go back to first screen but it does not solve the problem.
    DOES ANYONE HAVE A SIMILAR SYMPTON LIKE THIS? 
    Thanks for your advice.
    On the order detailed screen, I create a container with screen 100 and write PAI, PBO like this:
    Screen 100:
    process before output.
      module status_0100.
      module load_data_to_control.   "Load usage data to screen
    process after input.
    module user_command_0100.
    module status_0100 output.
      set pf-status 'PF100'.
      set titlebar 'T100'.
    endmodule.  
    module load_data_to_control output.
      if gr_cont is not bound.
        create object gr_cont
          exporting
            container_name = 'CONTAINER_100'
          exceptions
            others         = 1.
        if  sy-subrc <> 0.
          message a052(zvn) with
          ' No container object found'.
        endif.
        try.
            cl_salv_table=>factory(
            exporting
         list_display   = list_display
              r_container = gr_cont
          container_name =
            importing
              r_salv_table = gr_alv_2
            changing
              t_table = gt_orders
          catch cx_salv_msg into gr_error.
        endtry.
        perform set_functions.        " Set all standard function in screen 100
        perform set_column_order using gr_alv_2.       "Set column format, display
        perform handle_events.                       "Register events for selection mode & user commands
         Display order screen 0100
        gr_alv_2->display( ).
      else.
        gr_alv_2->refresh( ).
    endif.
    module user_command_0100 input.
      data: wa_d type gt_dtab,
            ls_contract type vbeln,
            ls_order    type vbeln,
            ls_invoice  type vbeln,
            ls_belnr type belnr_d,
            ls_row   type char10.
      data: l_text type char128.
        case  sy-ucomm.
        when 'RETURN' or 'BACK' or 'EXIT' or 'CANCEL'.
    *... refresh the table in order to see the new data
          gr_alv_2->refresh( ).
          leave to screen 0.
        when others.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT

    Hi ,
    When you are using the CL_SALV_TABLE, what is the use of screen 100. Better populate the evnts table in CL_SALV_TABLE
    Cheers
    Pavan

  • Creating a Detail Table Based on an Action in Another Table or Matrix to Display in the Same Report (Not a Drill-Through)

    Hello,
    I was wondering if it's possible have a matrix which shows total credits by month and have drill-down groupings to display the invoice numbers for each credit.  Then, once the drill-down is expanded for a particular month, be able to click on the invoice
    number and have another table under the matrix display the details of the invoice. 
    I don't really want a drill-through because that opens a different report in the window, what I want to be able to do is stay on the main report.  I also don't want to drill-into the invoice details from the matrix as that expands the matrix out and
    makes it unruly and ugly.  I've been playing with subreports but not able to get what I want out of it.
    I hope this makes sense - is there a way to do this in SSRS?
    Thanks!!

    Hi AvenueStuart,
    After testing the issue in my environment, we can refer to the steps below to work around the issue:
    Create a new table with the details of the invoice under the matrix.
    Add a parameter named invoice which get available values from the invoice field in the dataset.
    Right-click the [Sum(invoice)] cell to add an action with “Go to report” option, and specify the same report with the parameter below:
    Name: invoice                                                                 
    Value: [invoice]
    Right-click the table to add a filter in the table:
    Expression: [invoice]
    Operator: =
    Value: [@invoice]
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Join Between Dimension & Fact Table

    Hi all,
    Here is my scenerio:
    There are two tables, one dimension table and one fact table.
    Normally, they will be joined with a key, says Date_ID.
    However, these two tables do not have the same key.
    Question comes, can I create derived columns in both tables to pretend as key (the value of key assumes the same) and join them together? If yes, which layer (physical or business logic) to do the join? Will data be shown in Answer correctly?
    Thanks.

    Thanks for reply.
    I know that if two tables have the same key, says primary key and foreign key, they can be joined directly.
    However, the tables do not have the same key/column for join.
    Actually, I've tried to create dummy columns in both tables to join together in physical layer. Then use those dummy columns in business model layer to get the value from other columns. Complex join is carried out later in business moel layer. But it seems that it does work.

  • Join between two nested tables question

    Hi. I have two nested tables with a join statement drawing info from both. The query looks like this:
    select to_char(N.LASTLOGONDATE, 'YYYY'), count(n.u_name), A.ACCOUNTDISABLED
    from coclastlogon, TABLE(COCLASTLOGON.RLLS) N , userpwaudit, TABLE(USERPWAUDIT.PVSS) A
    where N.U_NAME = A.USERNAME (+)
    and coclastlogon.AUDITID = 12
    and userpwaudit.AUDITID = 12
    group by to_char(N.LASTLOGONDATE, 'YYYY'), A.ACCOUNTDISABLED
    The query runs fine except its not generating non-matching values from the A.ACCOUNTDISABLED field. It is my understanding that placing the (+) will instruct the statement to add these columns to the result. If I use the same query with the same unnested data it produces the non-matching result set as I require.
    My feeling is there might be an issue with the way I've set my "FROM" but I'm not too sure how to proceed.
    Any suggestions?
    Thanks!

    You're right, by non-matching I mean null values.
    Running the query I wrote returns this result:
    (N.LASTLOGONDATE,'YYYY') / COUNT(N.U_NAME) / ACCOUNTDISABLED
    2005 3408 No
    2002 1 Yes
    Running the query using un-nested data returns this result (this is what I'm after):
    (N.LASTLOGONDATE,'YYYY') /COUNT(N.U_NAME) /ACCOUNTDISABLED
    2005 3408 No
    2002 1 Yes
    2005 27 -
    As you can see, the value I'm after is the one with ACCOUNTDISABLED 'null' value. Essentially, "coclastlogon, TABLE(COCLASTLOGON.RLLS) N" has more values in the N.U_NAME column than the table it is being joined to. That is why I added the (+). I just need to account for all values in TABLE(COCLASTLOGON.RLLS) than just the ones that find a join with "userpwaudit, TABLE(USERPWAUDIT.PVSS) A"

  • Join between 2 large tables

    I've got 2 tables: pay_run_results (+/- 35.000.000 records) and XX_PAY_COSTS (25.000.000 records)
    When in join those table i get an error: ORA-01652: unable to extend temp segment by 128 in tablespace temp1
    So i thought the temp space would be to small. But a dba'er told met the temp space is 4,4 GB
    To reduce the total records i join a other table. see below
    select
    from
    pay_run_results,
    XX_PAY_COSTS,
    PAY_PAYROLL_ACTIONS
    where
    PAY_RUN_RESULTS.RUN_RESULT_ID = XX_PAY_COSTS.run_result_id
    and PAY_PAYROLL_ACTIONS.PAYROLL_ACTION_ID = XX_PAY_COSTS.PAYROLL_ACTION_ID
    and PAY_PAYROLL_ACTIONS.ACTION_TYPE ='C'
    and XX_PAY_COSTS.DEBIT_OR_CREDIT = 'C'
    When running the above query it took 44 minutes to complete, but i did not get the ora-01652 :)
    So I got 2 questions:
    1) why you get an error ORA-01652 when not sorting in your query. Is the temp space also used for temporaly save the result of a query? The result must give +/2 25.000.000 records
    2) The query below gives +/- 3.000.000 records. But still running for 44 minutes. How do you know what's normal? I think 44 minutes is quite long.
    Tnx for helping....

    You'll need to provide more information like database version, execution plan (or even better: a tkprof/trace report with wait events).
    It is explained here:
    http://oracle-randolf.blogspot.com/2009/02/basic-sql-statement-performance.html

  • Joins between AP Invoices tables and supplier tables.

    Hi Gurus,
    Hope you all are doing good.
    I require one urgent help from all of you.
    I want some data from bellow tables.
    ap.ap_invoice_distributions_all
    ap.ap_invoice_lines_all
    ap.ap_invoices_all
    ap.ap_suppliers
    ap.ap_supplier_sites_all
    ap.ap_tax_codes_all
    When I am joining these tables it is taking a lots of time to return the record.
    Mostly all the tables have more then 2536689 count.
    Could any body just give me the best joining condition for the above tables so I can validate the join.
    Its Urgent.

    ap.ap_invoice_distributions_all > join on tax_code_id to ap_tax_codes_all.tax_id
    ap.ap_invoice_distributions_all > join on invoice_id to ap.ap_invoices_all
    ap.ap_invoices_all > join on vendor_id to po_vendors
    ap.ap_invoices_all > join on vendor_id and vendor_site_id to po_vendor_sites
    Hope this helps,
    Sandeep Gandhi

Maybe you are looking for

  • After updating to IOS 7, my iphone won't connect to my Itunes

    Alright, this is what's wrong. I have an iphone 4s, which has always been working perfectly, but I decided to update it to the IOS 7 when it became available. Once I had updated, which took forever, it seemed to work just fine again although very dif

  • Mbp slow after yosemite install

    System is really slow it becomes tremendous  slow after getting back from suspended state. seems today's system update has improved the performance a bit. ** also the webcamera doesnt load at times after geting back from suspended state Problem descr

  • PS6 Bridge cache problem

    work with an Imac, version Moutain Lion 10.8.2 and with PS6. I get this message when opening PS6 Bridge, see upper section of the annex. If I click Ok pressure I can continue working.Don't know what good that cache content and for which this actually

  • Can't find Add a Device option Photosmart C4700

    I have a Photosmart C4700 that I am trying to set up wirelessly. I had it working once before, and for some reason it no longer works. After MUCH trial and error, I have been able to set it up again to work while connected to my MacBook Pro (running

  • How long does it take to receive email receipts for App Store purchases?

    I've been using iTunes for awhile but only recently got an iPhone.  Whenever I've purchased music from iTunes I would usually get an email receipt same day or next day.  I purchased my first iPhone app from the App Store five days ago but still have