Query Question: Sum of master and monthly table data

Hi All,
I have two tables that store financial data about programs. The PROGRAM table has the following columns (for purposes of this discussion):
ID, INITIAL_BUDGET, COST_CENTER
The PROGRAM_MONTHLY table has the following (abbreviated list of) columns:
ID, PROGRAM_ID (FK to PROGRAM.ID), CURRENT_FORECAST, RECORD_DATE
Every month, a copy of the program_monthly records for last month is made to new records in the PROGRAM_MONTHLY table and we use RECORD_DATE for our filters and comparisons. This way we have historical data, plus current month data that can be updated by our financial systems and program managers.
I am using Application Express and would like to create a dashboard chart that shows the summary of the INITIAL_BUDGET and the CURRENT_FORECAST for a selected month. Obviously, the INITAL_BUDGET doesn't change, but the CURRENT_FORECAST (and similar columns such as the amount committed to purchase orders, which were omitted to simplify the discussion) change monthly.
My goal is to create a chart that can display the initial budget, current forecast, amount committed on purchase orders, etc. for all cost centers, or just one at a time as the user requires, that is filtered by the month of the PROJECT_MONTHLY record. If I can come up with the statement for a view or query, then I can manage the rest.
The required syntax for the chart is "SELECT link, label, value FROM...", where "link" can be NULL, since is it an optional link to another URL. The "label" and "value" portion are the important parts.
For example, I have another chart that shows the project status (which is a Varchar 2 constrained to values such as, Active, On-Hold, Completed, etc.) with the status as the label and the count of the rows as the value. It starts:
select null link, pjm.PROJECT_STATUS label, COUNT(pjm.ID) value FROM ... However, I have been unable to come up with a query that generates the desired results for these PROGRAM and PROGRAM_MONTHLY tables. I have played with various types of joins and sub-queries, but my SQL just isn't up to the challenge yet. I realize that I might have to re-work the table structure to accomodate this requirement.
I would greatly appreciate any guidance in approaching this problem.
Many thanks for your time and help,
Petie

Certainly, Warren, thanks so much for your willingness to look at my problem.
To keep things simple, I will put the fundamentals of the tables with sample data. Please let me know if you would like more and I would be happy to provide it.
Table: PROGRAM
ID   PROGRAM_NUMBER   INITIAL_BUDGET   COST_CENTER
1   10001            100000           500-001
2   10002            125000           500-001
3   10003            150000           500-002
4   10004            175000           500-002
5   10005             10000           500-003
6   10006            200000           500-004Table: PROGRAM_MONTHLY
ID   PROGRAM_ID   CURRENT_FORECAST  RECORD_DATE
1    1            95000            02-FEB-06
2    2           125000            02-FEB-06
3    3           145000            02-FEB-06
4    4           180000            02-FEB-06
5    5             9000            02-FEB-06
6    6           225000            02-FEB-06
7    1            97500            02-MAR-06
8    2           120000            02-MAR-06
9    3           145000            02-MAR-06
10    4           185000            02-MAR-06
11    5            10000            02-MAR-06
12    6           215000            02-MAR-06
Report Example 1
When a user would like to see the current summary data for all cost centers, they would see a chart with the following data:
INIT_BUDGET  CURRENT_FORECAST
760000       772500
Report Example 2
When a user would like to see the summary data for all cost centers for last month, they would see a chart with the following data:
INIT_BUDGET  CURRENT_FORECAST
760000       779000
Report Example 3
When a user would like to see the current summary data for cost center 500-001, they would see a chart with this following data:
INIT_BUDGET  CURRENT_FORECAST
225000       220000I hope this better illustrates the solution I seek.
Thank you again for your time and assistance
Petie

Similar Messages

  • Master and Details Tables Data

    Hi all
    I have two tables one is Master table and other one is Details table.
    How to write a query to get Master as well as Details table data.
    Detail table contain more than one record for particular Master Record.
    Pls Help me.

    My version is Oracle 9i
    My Tables structures are :
    SQL> desc TFMS_CONTRACT_PRICES
    Name Null? Type
    ITEMNUMBER NOT NULL VARCHAR2(30)
    ITEMDESCR VARCHAR2(2000)
    PRICE NOT NULL NUMBER
    UOM VARCHAR2(30)
    UNITSAWARDED NUMBER
    DELIVERYPERIOD NUMBER
    COMMENTSREASON VARCHAR2(15)
    TOTALPOINTSSCORED NUMBER
    FREEDELIVERY VARCHAR2(250)
    YEAR VARCHAR2(15)
    UPDATEDBY NOT NULL NUMBER
    UPDATEDON NOT NULL TIMESTAMP(6)
    BRANDID NOT NULL NUMBER
    CONTRACTORID NOT NULL NUMBER
    ISPRICEESCALATED NOT NULL CHAR(3)
    SQL> desc TFMS_ACCESSORIES_MASTER
    Name Null? Type
    ACCESSORYID NOT NULL NUMBER
    ACCESSORYNAME NOT NULL VARCHAR2(150)
    DESCR VARCHAR2(250)
    ISDELETED NOT NULL CHAR(1)
    UPDATEDBY NOT NULL NUMBER
    UPDATEDON TIMESTAMP(6)
    CONTRACTORID NOT NULL NUMBER
    Sample Out put:
    ITEMNUMBER ACCESSORYNAME
    RT57-01-13-01 Truck ToolBoxes,Riding Sun Glass
    RT57-01-13-02 Door Guard,Maruthis
    For one item number there may be one accessory name or more than one accessory name.i need to display accessory names with delimeter(,).
    Pls help me.
    Thanks in Advance.

  • Problem with Master and Child table

    Hi,
    Working in jdev 11.1.1.2.0. I have one strange issue. i have master and child tables, the model is working fine with the view link. but when drag drop the same into my jsff. when i query the result 1st time 2 tables are refershing properly and data is coming. but the when i trying to select another row in the 1st table my 2nd table(child table) is not refreshing.
    i put partial trigger of the 2nd table as 1st table id.
    can any one help wht is issue here.
    Edited by: user5802014 on Jul 15, 2010 3:44 PM

    Check this post might help you
    http://baigsorcl.blogspot.com/2010/03/creating-master-detail-form-in-adf.html

  • Master and Document Tables ...

    What relation do Master and Document tables have to parent and child tables?
    Should I declare all my created tables master and master details ? 
    how can I establish my relationships, foreign keys and primary keys with all these fields created by SAP ?

    Hi Neftali,
    You can create UDOs by using DI API, you have many threads talking about it in this forum.
    If you don't want to use UDOs (which are very useful) then you should not use MasterData,... tables because this tables shouldn't be modified by using SQL queries. These kind of tables are designed for use with UDOs to avoid the whole management of the Forms for the Add/Update/Find/Delete,... actions.
    Have you had a look to B1DE? You can download it from main B1 page in SDN for free and it generates for you the code of your addon for managing many of the aspects of the B1 SDK. You can maybe give it a try!
    You can block users from viewing/using specific menus in B1 by using the UI API.
    Regards
    Trinidad.

  • How to show master and detail tables in different pages?

    Hi,
    Can somebody expalin me how to include or bind the master and detail tables to different pages which are included at runtime.
    thnaks,
    Naresh.

    Hello!
    you have ti create a Master/Detail data structure.
    In the first page drag the master table, on the second drag a detail table.
    It should work out of the box. Selecting a record on the master table selects
    the details on the detail table automatically!
    regards,
    Mario Udina

  • How can we delete SID table data and Text table data

    Hi,
    How can we delete SID table data and Text table data of any
    InfoObject.

    Hi,
    Go to transaction SE14, give the technical name if the table:
    /BIC/T<InfoObject Name>   for Text Table
    /BIC/S<InfoObject Name>  for SID Table
    Select "Table" in the given 4 options below  &  hit Edit button.
    in the next screen select "Direct"
    & also select "detele data" radio button.
    & hit  "Activate & adjust database".
    this will delete the complete data from the tables.
    Note: before deleting the SID's make sure of the consequences & after effects.
    Also the SID gets generated the next time you load master data/transaction data only for those records which were loaded..
    Regards,
    Iliyas

  • Export and import table data with Java

    I need a library for simple exporting and importing table data.
    The data should be exported to a SQL file with insert statements.
    I just want to tell the library the table name, the connection and where to store the file. The usage should be very simple.
    Are there any small libraries for this? Finished calsses and methods which I can just call?

    I need a library for simple exporting and importing
    table data.
    The data should be exported to a SQL file with insert
    statements.Every database has utilities to export/import data from tables. Take a look at your database manual.

  • Cmd to export and inport table data of a paticular schema

    hi,
    can anyone tell me the cmd to export and inport table data of a paticular schema

    Exp userid=system/pass owner=SCOTT rows=Y triggers=Y
    Imp userid=system/pass file=expdat.dmp fromuser=SCOTT touser=NEW commit=yes log=log.txt

  • Master and Details Tables

    Hello Experts,
    While entering any transactional document, like DO or SO system enter the data in a Master Table for example in ODLN and DLN1. that is ok
    is there any other table in which system keeps the reference. for a document entered.
    Help Required.....

    Thanks for reply,
    actually I was trying to ask that other than ODLN and DLNx tables is there any other table in which system keeps the track for checking the integrity of data / document i.e. like if we have entered document 
    number 10036,
    will system keep the track of this document in any other table other than ODLN and DLNx tables ....
    help required.
    Edited by: Rui Pereira on Apr 30, 2009 2:00 PM

  • Delivery Block at PGI level based on GI date and Month end date

    Business need a check on delivery processing based on the Planned GI date, Month end date and transit period. This transit period is a custom field and dependent on customer. Also it is not maintained anywhere in system. Business store it in some excel format.
    The logic needed is: For any given month, the delivery order MUST be goods issued in the same month, i.e. once the order is delivered, the Post goods issue should ONLY be allowed if and only if , the PLANNED GI date ( as maintained in delivery ) + transit time ( at customer level ), falls within the month end date. If not, a block should be applied at PGI and only authorized personnel should be able to release that block.
    Also, there will be no check at invoicing VF01 level. Once the PGI blocked is removed, there will be no check on invoicing. The month end date may vary month to month and need to in combination of Sales Org / Plant as mentioned
    In addition, the business need an exception report where the information of releasing the block should appear for release date, user id of the responsible person, time sales order no etc. and it should be downloadable.
    We can have a custom table to maintain the month end day in given combination.
    But I need your expert inputs as-
    1-     Can we add this transit period in at customer master data as it is dependent on customer and there are huge no of customers for the sales unit? If not, then how to maintain it; may be a z table?
    2-     Based on this logic, what should the code/logic to be written for block at PGI.
    3-     How to control the authority check for removing the block.
    4-     The source fields for exception report.
    Pls revert accordingly.
    Many thanks in advance.

    Hello,
    Please refere the answers to your questions:
    1- Can we add this transit period in at customer master data as it is dependent on customer and there are huge no of customers for the sales unit? If not, then how to maintain it; may be a z table?
    You can either use some un-used Feild in Customer Master or maintain a Z-Table. I believe maintaining a Z-Table would be easy as you have huge number of Customers. You can also write a dmall program to Pick the Customer-wise transit dates from a excel file & store in Z-Table.
    2- Based on this logic, what should the code/logic to be written for block at PGI.
    You have explained the requirement well in your thread, you need to explain the same to your ABAPer & Basis person & they would do the needful.
    3- How to control the authority check for removing the block.
    Basis person would create & assign a Z-Authorization object which the ABAPer would use in his program.
    4- The source fields for exception report.
    Once you do the above development, your ABAPer will easily pick the required feild in Report as he has already used all the feilds somewhere in his development.
    Hope this helps,
    Thanks,
    Jignesh Mehta

  • How to get ONLY month and MONTH within date...

    I have to convert something from sql server to oracle.
    In SQL Server I have:
    SELECT
             TEXT_26 AS CostUnit,
             MILESTONE_DATE AS ContractShipDate,
             ACTUALFINISH AS ActualShipDate FROM PROJ_TASK
    WHERE
              TEXT_29='SHIP'
              AND NAME NOT LIKE 'CMSB%'
              AND NAME NOT LIKE 'CCFB%'
              AND (MONTH(ACTUALFINISH) = MONTH(GETDATE()) - 1)All seems very simple SQL except I don't know how to convert that last line:
    ...         AND (MONTH(ACTUALFINISH) = MONTH(GETDATE()) - 1)Basically Im just extracting the month so that I say the MONTH of the actual finish date is equal to the month of Today - 1. Meaning get the month for today (GETDATE() in sql server) and then subtract ONE month from it.
    How can I do that line in oracle?
    Thanks,
    Jon

    I generally find it simplier if one answers the question I posedYou need to realize that with free advice and help you get what you pay for. If you want people to run the statements for you then you should provide create table and sample data scripts.
    Another alternative is
    trunc(actualfinish,'mm') = add_months(trunc(sysdate,'mm'),-1)http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions201.htm#i79761
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions004.htm#i76717

  • Query to track changes to a particular table data

    Hi,    
        Do we have some query to track the chnages to a particular table data?how we can do that...please helppp
    Regards
    Aswathy

    The answer can only be as good as the question.
    Your question is not good: there is no detail.
    Say exactly what version of Oracle you have.
    Say for how long in the past you need to track the changes.
    Partial answer: for changes in the last few hours, read Flashback Queries
    Message was edited by: Stew Ashton
    P.S. I forgot to ask: do you want to know WHO and WHEN data was changed, or WHAT data was changed? Hoek answered the first question, I gave a partial answer to the second.

  • How to filter parent and child tables data in impdp?

    Hi Friends,
    i hope everyone doing good..
    I have two tables in my schema like below.
    STUDENT_DTLS:-
    SID Sname CID
    1     venkat     001
    2     uppy     002
    3     deepu     003
    4     trinath     003
    5     naveen     004
    6     ramesh     005
    COURSE_DTLS:-
    CID CNAME Fee
    001     Oracle     2000
    002     java     6000
    003     sieble     4000
    004     informatica     3000
    005     obiee 4000
    if I load only few Student details say sid=1,2,3 into another environment using impdp,corresponding to those students course details from COURSE_DTLS table only need to be loaded.Not all course details.
    Iam Expecting Result in new schema as below:-
    SID Sname CID
    1     venkat     001
    2     uppy     002
    3     deepu     003
    CID CNAME Fee
    001     Oracle     2000
    002     java     6000
    003     sieble     4000
    But when i am using the below import scrit,The COURSE_DTLS is loading first and its query option(select cid from STUDENT_DTLS) is returning no rows.Because at that time no data is insertred into STUDENT_DTLS yet.
    secondly it is importing data into STUDENT_DTLS with query option where sid=in (1,2,3) which is loaded propelry.
    Thirdly it is trying to enable primary key and Foreign key constraints which is also failing because of no data in COURSE_DTLS table.
    i have changed the order of tables in TABLES clause like tables=COURSE_DTLS ,STUDENT_DTLS.But still COURSE_DTLS table is loading first.
    impdp pa_data_sub/******* NETWORK_LINK=qdssih30 tables=STUDENT_DTLS,COURSE_DTLS query='STUDENT_DTLS:"where SID IN(1,2,3)"','COURSE_DTLS:"where cid in(select cid from STUDENT_DTLS)"', CONTENT=all table_exists_action=replace directory=DATA_PUMP_DIR logfile=exp_join.log
    output:
    Total estimation using BLOCKS method: 128 KB
    Processing object type TABLE_EXPORT/TABLE/TABLE
    . . imported "PA_DATA_SUB"."COURSE_DTLS" 0 rows
    . . imported "PA_DATA_SUB"."STUDENT_DTLS" 3 rows
    Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
    ORA-39083: Object type REF_CONSTRAINT failed to create with error:
    ORA-02298: cannot validate (PA_DATA_SUB.SYS_C0040905) - parent keys not found
    Failing sql is:
    ALTER TABLE "PA_DATA_SUB"."STUDENT_DTLS" ADD FOREIGN KEY ("CID") REFERENCES "PA_DATA_SUB"."COURSE_DTLS" ("CID") ENABLE
    Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    Job "PA_DATA_SUB"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 17:28:13
    Please suggest me how to achieve this task in a single import command?
    Is there any option in impdp to prioritize the table to be loaded first?
    Thanks,
    Venkat Vadlamudi

    You can't be guaranteed which order the data will be loaded in, so using a query that examines a table that is being imported is not going to always work the way you want it. The failing constraints makes sense because there is no data.
    So, in your case, course_dtls gets imported first and the table student-dtls exists, but it not populated yet, so the select cid from student_dtls comes back with 0 rows. The second query works fine.
    You might be able to change the query to be:
    'COURSE_DTLS:"where cid in(select cid from STUDENT_DTLS@qdssih30 where SID IN(1,2,3)"'
    This way, you query the source table pointed to by the network link and you use the same subquery from the first table.
    This should work for you... I think anyway.
    Dean

  • 2 master pages with table data flow

    Hi,
      My form got 2 master pages. Each master page will display atleast once in the output preview. First page displays table data which may or may not flow to the second page depending on the no.of records. But, the form will show both the master pages in pdf preview( even if the second master page is empty).
      Now, I have a field in the both the master pages which will show the total amount. Total amount field will have a value which should be displayed in the first page if the data doesn't flow to the second page. The total should display in the second page if data flows to the second page. Where can I write the condition and how will I know whether the form is flowing to the second page or not? I cannot write based on the pagecount because the output will always contain 2 pages.
    How will I know my table is flowing to the next page or not so that I will write my logic based on it.
    Thanks,
    kc

    Hello Dude,
    Try to find out the field of the table is in which page. If it is in page 2 so u can print the amount there.
    try this script
    for(var i = 0 ; i < xfa.host.numPages ; i++)  // loop uoto total number of pages
      var oFields = xfa.layout.pageContent(i, "field"); 
      totalfields   =  oFields.length;                    // gives the number of fields in a page
       flag=1;      
      for (var nNodeCount = 0; nNodeCount < z; nNodeCount++)  // loop through the fields
             if (oFields.item(nNodeCount).name == "find your table field")   // Here find for that field if it works print maount in that page
    Good Luck
    Regards,
    RAkesh

  • ICal events are missing Day and Month in date

    Hello, Sorry if this has been addressed elsewhere - this is such a weird fault I was not sure how to search for it.
    My iCal events are missing the Day and Month in their start and end dates - it just shows a 4 digit year which can only be edited as a 4 digit number. All my events are in their correct places but I am unable to create new multiday events.
    This applies to old and new events alike. I tried trashing my iCal prefs file but it made no difference.
    Anyone any ideas? I am using iCal 3.0.8 on Leopard 10.5.8.
    Thanks in advance.

    Worked it out - I was using a custom date format to give me day and date in the menu bar - reverting to one of the standard built in 'British' works - but then I lose my day in the menu bar....

Maybe you are looking for