How to select header group with detailed data in one SQL

Dear,
I would like to have a little help from you. My goal is to create a view where data must be in appropriate format. In this format i would like to have for each group one header.
I have 3 tables which they ar connected to each other (representing hierachical data where financial plan breaks across different groups).
CRM_PLAN
CRM_PLAN_ID
DATE
AMOUNT
CRM_PLAN_PE
CRM_PLAN_PE_ID
TITLE
AMOUNT
CRM_PLAN_ID (ref key to CRM_PLAN.CRM_PLAN_ID)
CRM_PLAN_MONTH
CRM_PLAN_MONTH_ID
YEAR
MONTH
AMOUNT
CRM_PLAN_PE_ID (foreign key to CRM_PLAN_PE.CRM_PLAN_PE_ID)
Data looks like:
CRM_PLAN
CRM_PLAN_ID | DATE | AMOUNT
1 | 01.01.2012 | 500
2 | 01.02.2012 | 200
CRM_PLAN_PE
CRM_PLAN_PE_ID |TITLE | AMOUNT | CRM_PLAN_ID
1 | Organization 1 |100 | 1
2 | Organization 2 |400 | 1
3 | Organization 3 |200 | 2
CRM_PLAN_MONTH
CRM_PLAN_MONTH_ID | YEAR | MONTH | AMOUNT | CRM_PLAN_PE_ID
1 | 2012| 1 | 60 |1
2 | 2012| 2 | 40 |1
3 | 2012| 1 | 350 |2
4 | 2012| 2 | 50 |2
5 | 2012| 1 | 200 |3
I would like view which would return data like:
MONTH | AMOUNT
Organization 1 |null
1 | 60
2 | 40
Organization 2 | null
1 | 350
2 | 50
Organization 3 | null
1 | 200
The main question is hot to write an sql as source for view to insert before each group a row with title column value from table CRM_PLAN_PE. Is that even possible? Maybe you could suggest me some other method.
View will be used in oracle form where will be possible to edit data - I will arrange that through insted of trigger.
Regards,
Igor
Edited by: user5528050 on 29.11.2012 2:23
Edited by: user5528050 on 29.11.2012 2:24
Edited by: user5528050 on 29.11.2012 2:25

Hi, Igor,
user5528050 wrote:
... I would like view which would return data like:
MONTH | AMOUNT
Organization 1 |null
1 | 60
2 | 40
Organization 2 | null
1 | 350
2 | 50
Organization 3 | null
1 | 200
The main question is hot to write an sql as source for view to insert before each group a row with title column value from table CRM_PLAN_PE. Is that even possible? Maybe you could suggest me some other method. So, you want to have 2 different kinds of rows in the output:
(1) "parent" or "master" rows containing data from crm_plan_pe, such as
MONTH          AMOUNT
==============     ======
Organization 1(2) "child" or "detail" rows containing data from crm_plan_month, such as
MONTH          AMOUNT
==============     ======
1          60Sure, you can do that.
One way is to do a UNION of 2 separate queries: (1) to generate just the parent rows, (2) to generate just the child rows.
You could also join the 2 tables and use GROUP BY GROUPING SETS. The super-aggregate rows would be the parent rows.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved (it looks like crm_plan is not involved in this problem), and also post the results you want from that data. You need to post this whether or not you want SQL code in reply. The people who want to help you want to provide good answers, and that means they want to re-create the probelm and try their ideas.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002}

Similar Messages

  • How to create a group with multiple data fields

    Post Author: RichS
    CA Forum: Formula
    Using CR XI.  Using CSV input from ODBC text driver.  No problems here.
    There are 3 fields that I want the same group by action.  Is this possible?) 
    If any one of these 3 fields change I want some header information and column fieldnames to display.  The header information I only want displayed on the first page (on the change) and the column fieldnames to display on every page.  I have played around with things like "InRepeatedGroupHeader" and "report group header on each page".  I am not getting all the results that I am looking for though.
    I want report to look like:
    Page header stuff  (to display on every page)  This data consists of some fields that will have static data and will display on every page.  And it consists of 3 non-static fields that I want to group on. 
    Group header stuff that I only want displayed on the first page on a change from one of the 3 fields mentioned above.
    Column headings that I want displayed on every page.
    Details data
    Group footer stuff (details not important for this)
    I get the expected output (column headings displayed on every page, and group header stuff display on the first page on each group change) with one group field.  But I want the group change to happen for all 3 fields.
    It seems simple but I can't find a way to create a "group" so if "field1 or field2 or field3" change, I get the same "group by" action.  I just need to know how to get the expected action.
    I expect that I might have some terms mixed up and/or some important information that would aide you in helping me.  If that is the case please re-post and I will add any missing or mis-stated information.
    Thanks,

    Post Author: V361
    CA Forum: Formula
    I am slightly confused, but perhaps you can create a formula
    Then group on the formula.  If this is not what you want, could you post some sample data, with the desired results.

  • How to select the column with respect to language in sql server

    USE Master
    SELECT * FROM SysMessages
    GO
    when i execute the above query, in description column am getting English and Chinese , here if i want to select only English .
    how can i select only English language by using WHERE condition.
    And why am getting data in Description column in Chinese also any reason behind it.
    If there is any reason please suggest me.

    Bro , here am not getting what is Unicode and all
    Specially ,
    Why does we need N' string ' while inserting and Why we need to place N and String in Unicode while inserting data and what does it mean.
    Insert into T1 Values
    (N'找不到由給定的 @article 或 @artid ''%1!'' 所參考的物件。'),
    (N'Unclosed quotation mark after the character string .')

  • Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount 28

    Post Author: tadj188#
    CA Forum: Formula
    Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
    Background:
    1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using  subreports.    A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report    with their respective detail lines).  I had multiple subreports and each subreport became one union.
    Created and tested, already:
    1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
    Issue:
    1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
    Other Ideas Appreciated:
    1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
    Thank you.
    Tadj

    export all image of each page try like this
    var myDoc = app.activeDocument;
    var myFolder = myDoc.filePath;
    var myImage = myDoc.allGraphics;
    for (var i=0; myImage.length>i; i++){
        app.select(myImage[i]);
        var MyImageNmae  = myImage[i].itemLink.name;
        app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
        app.jpegExportPreferences.exportResolution = 300;
           app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
        alert(myImage[i].itemLink.name)

  • Grouping with 2 date in sql server

    totle_count
             dt
             name   
    program_id
    1
      1/3/2015
      Tea
    14
    1
      1/5/2015
      Tea
    14
    1
      1/6/2015
      Lunch
    13
    17
    1/6/2015
      Tea
    14
    2
    1/9/2015
      Breakfast
    1008
    39
    1/10/2015
      Breakfast
    1008
    4
    1/19/2015
      Breakfast
    1008
    1
    1/19/2015
      Dinner
    1009
    3
    1/21/2015
       Tea
    14
    totle_count
              dt
    name
    program_id
    1
       1/6/2015 and 1/8/2015
      Lunch
    13
    2
       1/3/2015 and 1/5/2015
      Tea
    14
    17
       1/6/2015 and 1/9/2015
      Tea
    14
    3
       1/21/2015 and 1/23/2015
      Tea
    14
    41  
    1/9/2015 and 1/11/2015
     Breakfast
    1008
    4
       1/18/2015 and 1/20/2015
     Breakfast
    1008
    1
       1/18/2015 and1/20/2015
    Dinner
    1009
    Here is 2 table, 1st is my row table, and I want to group with 2 date.
    Here is 3 days difference. and sum of value is coming.
    2nt table is my expectation table.
    Plz help me for this problem.
    Thanks
    Samir

    I am doing 3 days grouping here
    "dt" is name of date column
    if "dt" column has '1/19/2015' then next in group it will come in "1/18/2015 and1/20/2015"
    any date of 18 or 19 0r 20 it will come in "1/18/2015 and1/20/2015"
    and counting will add between 3 date
    Sorry your posted output is not as per above rule
    How did row for  1/6/2015 and 1/9/2015 got included then. If you group by 3 days you wont get
    this row as 6-9 is 4 days not 3 days
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to sync contacts group with Ovi PC suite or Ov...

    Hi
    I have a N97 with latest firmware.
    Does anybody know how to sync contacts group with Ovi PC suite or Ovi.com?
    I go to the option in (Menu/Settings/Connectivity/Data transfer/Sync/), then edit profile.
    But don't know how to define the database of contacts group.
    Anybody knows? Thanks

    Hi you can sync groups with Ovi suite on your computer, you can also edit them by right clicking a contact and adding to group !
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • How to put a check with the date

    Hi,
    I have created a ztable with 3 fields .
    clientcode(3),
    date,--date geneated
    version--- fileversion
    i need to update this table everytime i execute the data. Every time version shd get incremented when i execute the program.  When i excute the program next day version shd be updated by '1'.
    i wrote the code for version updated i'm not getting the logic how to put a check with the date.
      SELECT *
       FROM zfi_enetflver
       INTO TABLE gt_flver.
      SORT gt_flver DESCENDING.
      CLEAR: gv_dt, v_file.
      CONCATENATE sy-datum6(2) sy-datum4(2) INTO gv_dt.
      READ TABLE gt_flver WITH KEY client_code = gv_clcd.
      IF sy-subrc = 0.
        idx = sy-tabix.
        IF gt_flver-zdate = ' '.
          gt_flver-zdate = sy-datum.
        ENDIF.
        IF gt_flver-version = ' '.
          gt_flver-version = '001'.
          gv_filever = gt_flver-version.
          MODIFY gt_flver INDEX idx TRANSPORTING zdate version.
          MODIFY zfi_enetflver FROM TABLE gt_flver. "TRANSPORTING version.
          CONCATENATE 'E:\' 'ENET\' gv_clcd gv_dt '.' gt_flver-version INTO v_file.
        ELSE.
          gt_flver-version = gt_flver-version + 1.
          gv_filever = gt_flver-version.
          MODIFY gt_flver INDEX idx TRANSPORTING version.
          MODIFY zfi_enetflver FROM TABLE gt_flver .
          CONCATENATE 'E:\' 'ENET\' gv_clcd gv_dt '.' gt_flver-version INTO v_file.
        ENDIF.
      ENDIF.
    clientcode is the key field in ztable do i need to make date field key ??
    please help me with the logic

    You need to implement below logic:
    1. check if field_date = sy-datum. in this case do nothing.
    2. else . move sy-datum to field_date .
    3. modify your internal table with field_date .
    4. populate final table to database table .
    hope you get it.

  • PLD:  How to decrease Header along with PLD.

    How to Decrease Header along with paper size from A4 to half (Width= 648 Hight= 432),

    I am sorry, but I don't know the solution for your problem - like apparently the rest of the SDK community here.
    This Forum is (mainly) for SAP Business One SDK.
    For questions related to the B1 application itself and around customization the "Implementation" forum in the Channel Partner Solution Network (http://p2p.sap.com/businessoneforum) - or a message to SAP Support - would IMHO be the best options.
    Thanks,
    Frank
    Message was edited by:
            Frank Moebius
    ...but THANKS for the excellent subject you used! I am glad to see someone giving such precise information in the subject!

  • How to create sharepoint Group with read only permissions using powershell for entire site ?

    How to create sharepoint Group with read only permissions using powershell for entire site (including subsites and top level site)

    Hi
    using (SPSite site = new SPSite(url))
    using (SPWeb web = site.OpenWeb())
    SPUserCollection users = Web.AllUsers;
    SPUser owner = users[string.Format("{0}{1}", "Domain", "Owner Username")];
    SPMember member = users[string.Format("{0}{1}", "Domain", "Default Member Username")];
    SPGroupCollection groups = Web.SiteGroups;
    string GroupName = “Super Exclusive”;//your group name
    string GroupDescription = “Super exclusive group description.”;
    groups.Add(GroupName, owner, member, GroupDescription);
    SPGroup NewSPGroup = groups[GroupName];
    SPRoleDefinition role = Web.RoleDefinitions["Read"];
    SPRoleAssignment roleAssignment = new SPRoleAssignment(NewSPGroup);
    roleAssignment.RoleDefinitionBindings.Add(role);
    Web.RoleAssignments.Add(roleAssignment);
    Web.Update();
    Please 'propose
    as answer' if it helped you, also 'vote
    helpful' if you like this reply.

  • How do you make groups with your contacts?

    How do i make groups with the contacts? i have a certain group of people i have to update weekly and dont want to have to click on all 14 of their names to tect them

    Create them in the Address Book application on your Mac. They will sync to iCloud
    If you want to create them in iCloud, log into iCloud.com on your Mac. They will sync back to your Mac Address Book.

  • Motion how to create 3d effect with a background and one primary object

    motion how to create 3d effect with a background and one primary object

    … like that?
    http://youtu.be/yOht1GJpEm4

  • Selectively Format Groups with Multiple Columns

    I have a bit of an obscure task I've been trying to hammer out to no avail.  I've searched quite a bit but can't seem to find anyone else who has attempted this.  I have two group by statements, one is a category and the other is a rank.  What I'm trying to do is organize the report so that there are category rows and below each category row is a set of columns for each rank with their associated values as such:
    category1
    rank1     rank2     rank3     rank4
    value1   value1    value1   value1
    value2   value2    value2   value2
    category2
    rank1     rank2     rank3
    value1   value1    value1
    value2   value2    value2
    I've tried using details>Section Expert>>Layout>Format Groups with multiple column.  Unfortunately, this applies to both groups putting the categories into columns instead of rows, making a mess.  Does anyone know of a way to selectively put groups into columns and ensure alignment?  In the above example the user would be able to compare rank values from multiple categories since they all line up.  Any help with this would be very much appreciated.

    Hi,
    Have you tried using a crosstab? Give this a shot:
    1) Group the report on Category
    2) Create a new group header section. Group Header b
    3) Place a crosstab in this section
    4) The columns would be the Rank field, I'm not sure about what you would like to show in the rows
    5) The summarized field would be the Value field ofcourse
    Let me know how this goes.
    -Abhilash

  • How to prompt for parameters (with details, please)

    Post Author: RainbowRiver
    CA Forum: Data Connectivity and SQL
    I have spent all afternoon on this. It should be fairly simple, but I just can't figure it out and the documentation is not helping.
    This is how the SQL Server stored procedure looks in Query Analyzer, and it works just fine:
    DECLARE @startDate datetimeDECLARE @endDate datetimeSET @startDate = '2007-11-01'SET @endDate = '2007-11-30'EXECUTE MonerisTransaction_ReportNotReconciledByDate @startDate, @endDate
    I have two parameter fields on the report for the two parameters of the stored procedure.
    In the database expert, if I select the stored procedure and click ">" to add it to the selected tables, there is no error message, but when I run the report, no data is displayed.
    If I add a command instead of a stored procedure, what do I type as the SQL query in the "Add Command To Report" text box? The only way I won't get an error message is if I enter the entire five lines of code above. I can add parameters by clicking the "Create" button, but if I don't enter the five lines of code above and I click OK, I get an error message that the start date parameter is missing.
    Why does it have to be so complicated?
    Can anyone help me? My job is at stake!

    Post Author: RainbowRiver
    CA Forum: Data Connectivity and SQL
    I've figured it out for those who have the same problem.
    On the Database Expert screen:
    1. Expand the "Current Connection" node.
    2. Right-click "Add Command" under your connection and select "Add Command to Report" from the drop-down menu.
    3. On the "Modify Command" screen, in the text box with the header "Enter SQL query in the box below", enter:
    DECLARE @organizationID intDECLARE @date datetimeSET @organizationID = {?organizationID}SET @date = {?date}EXECUTE Report_ReconciliationSummary @organizationID, @date
    4. Still on the "Modify Command" screen, In the list with the header "Parameter List", create the following parameters:
         organizationID
         date
    5. Click OK.

  • How to setup Business Group with Global Legislation?

    Hi All,
    We are exploring possibility of creating International Business Group with no Legislation Code for our client. The client has operations in multiple geographies.
    I found following document in Metalink
    How an International Business Group be created with no Legislation Code? [Doc ID 851711.1] It mentions "Global legislation must be installed in order to set up a Global Business Group. The business group is created just like any other, but with Global legislation selected. You will need to use Global responsibilities to access it."
    When we tried to create a business group with Legislation Code as 'Global" we did not find any such Legislation Code in dropdown of *Business Group Info classification.
    Has anybody implemented Global Legislation before? Any information on Setup Steps, Challenges faced, bugs and issues faced with other modules especially OTL would be appreciated.
    Thanks in Advance,
    Amit
    Edited by: user10450466 on Jan 22, 2010 12:23 AM

    I wasn't aware there's any such thing as 'Global Legislation' in HRMS and I think the Metalink Note you mention is misleading. There are multiple concepts here being mixed up.
    hrglobal and Data Installer
    Oracle deliver legislative seed data through hrglobal and Data Installer. When a DBA runs this they pick the legislations they wish to install. That includes legislations such as US, GB and all legislations where Oracle HRMS deliver seed data (Fast Formulas, balances, etc). One of the options here is 'Global', which ensures that common seed data used across multiple legislations is installed. This process does not create new legislations - it just creates the seed data used by those legislations. 'Global' is not a legislation - it just means that the relevant seed data (Fast Formula, balances, etc) is typically delivered without the legislation_code column being populated.
    Business Groups and Legislations
    A Business Group is intrinsically tied to a Legislation Code - they have a one-to-one relationship. When you define a Business Group you have to pick a Legislation and that list of Legislations comes from fnd_territories_vl. The list in fnd_territories_vl has nothing to do with hrglobal or Data Installer. There is no 'global' territory.
    International HR & Payroll
    If you are implementing HRMS in a country where Oracle HRMS do not deliver any specific legislative seed data or functionality (ie, the legislation isn't listed in Data Installer) you have the option of using International HR & Payroll. This allows you to install generic seed data into the legislation of your choice, which is again a list from fnd_territories_vl. Again, there's no concept of 'global' legislation. Information on that is available here:
    International HR and Payroll [ID 261452.1]
    International Implementations
    Customers, like yours, who are rolling out Oracle HRMS to multiple countries have a big choice to make: single or multi Business Group. If you opt for one Business Group you create employees in multiple countries all within the same Business Group. That Business Group is tied to just one of those country's legislation codes - which you go for is up to you but that's generally the Legislation Code of the International HQ. The problem with this approach is that you can't leverage the legislative-specific functionality for each of the other countries.
    If you opt for multi-Business Group you typically define one Business Group for each country so that you leverage the legislative-specific functionality for each country. This is generally more popular but doesn't suit everyone: you can have problems with employees transferring from one country to another, etc.
    Global Structures
    Oracle HRMS has forced you to tie a Business Group to a legislation code for many years. As mentioned above, this causes a number of problems. To mitigate those, Oracle have delivered a number of enhancements that help you model global businesses:
    1. Global Organization Hierarchies
    2. Global Security Profiles
    3. Global Overseas Deployment functionality (nickname GOD/GOLD)
    4. Cross Business Group profile option
    5. etc
    I hope that helps.

  • How to create a report with survey data

    Hi All,
    I need to create a report with survey data in below format. Can anyone help me how to display the summary in this format.
    Swapna

    Hi Swapna,
    According to your description, you want to create a report with survey data and display the summary.
    Reporting Services is used for rendering the report with data retrieved from datasource. In Reporting Services, we can retrieve data from the datasource then design a report, after the report processed, data is fixed on the report. So it’s not supported
    to have the end users selection and do summary. For your requirement, it’s can’t be achieved currently.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

Maybe you are looking for

  • Not able to generate excel file locally

    Hi guys, My web server & database server are on 2 different systems. I am trying to generate excel file locally but the excel is getting generated on server. Output path is     c:\\" + output + ".xls    There is no problem anywhere else in code. If a

  • Error in activating the data

    Hi Can any body explain what this error says. this error is caused due to some problem at BW side or DB side. <b>Error analysis An exception occurred. This exception is dealt with in more detail below . The exception, which is assigned to the class '

  • Setting up a Form Application to write to an XML file on a local computer

    First, I'm using Flash CS3, and Actionscript3. I'm trying to set up a data collection form that will save the results to a file that can later be imported into a database. This is going to be in a Kiosk at a tradeshow and it won't have internet acces

  • Problem in converting .txt to .pdf

    import java.io.*; import java.text.DecimalFormat; import java.util.*; public class StudentGrade public static void main (String[] args) throws IOException, FileNotFoundException //Declare Variables double test1, test2, test3, test4, test5; double ave

  • Catch / know XML Data of PDF Form (without do XML submit)

    Is it possible from within a PDF form, using JS get / know XML data of the current form? I need to get the same XML data that would be generated with "export data" feature of Adobe Professional. Thx!