How to get the sum by customer?

Hi, in this query below, I want all the s () basically summing up of each "INVESTOR_CODE", can anyone help please?
select 
b.INVESTOR_CODE ,
a.INVESTOR_NAME , 
b.DEPARTMENT_CODE , 
b.INVOICE_NO , 
b.INVOICE_TYPE , 
trunc(b.INVOICE_date) INVOICE_date, 
c.COMPANY_SHORT_NAME , 
sum(INVOICE_COMMISSION)  INVOICE_COMMISSION, 
sum(INVOICE_KEEPING)  INVOICE_KEEPING , 
sum(INVOICE_STAMP)  INVOICE_STAMP, 
sum(INVOICE_OTHER) INVOICE_OTHER,
sum(INVOICE_MISR) INVOICE_MISR,
sum(INVOICE_INSURANCE) INVOICE_INSURANCE,
sum(INVOICE_HAIAH)INVOICE_HAIAH
from investor a , invoice b , company c , DEPARTMENT d
where a.INVESTOR_CODE = b.INVESTOR_CODE
and b.COMPANY_CODE = c.COMPANY_CODE
and b.DEPARTMENT_CODE  = d.DEPARTMENT_CODE
and trunc(invoice_date) >= '14-AUG-07'
exists(select 1 from OPERATION_LINE_SMAEDAY ols where ols.INVOICE_NO  = b.INVOICE_NO and ols.INVOICE_type  = b.INVOICE_type  )
group by  b.INVESTOR_CODE , a.INVESTOR_NAME , b.DEPARTMENT_CODE , b.INVOICE_NO , b.INVOICE_TYPE , trunc(b.INVOICE_date) , b.INVOICE_TYPE,c.COMPANY_SHORT_NAME
order by b.INVESTOR_CODE  , INVOICE_date;

For this table, the following query will do the grouping and order it as you want. You will still combine it with the previous query using the original paintings.

SQL> select investor_code
  2       , investor_name
  3       , department_code
  4       , invoice_no
  5       , invoice_type
  6       , invoice_date
  7       , company_short_name
  8       , sum(invoice_commission)
  9       , sum(invoice_keeping)
 10       , sum(invoice_stamp)
 11       , sum(invoice_other)
 12       , sum(invoice_misr)
 13       , sum(invoice_insurance)
 14       , sum(invoice_haiah)
 15    from samedaydata
 16   group by investor_code
 17       , investor_name
 18       , rollup
 19         ( ( department_code
 20           , invoice_no
 21           , invoice_type
 22           , invoice_date
 23           , company_short_name
 24           )
 25         )
 26   order by investor_code
 27       , department_code
 28       , invoice_no
 29  /

INVESTOR_CODE INVESTOR_NAME   DEPARTMENT_CODE INVOICE_NO INVOIC INVOICE_DATE        COMPANY_SHORT_NAME   SUM(INVOICE_COMMISSION)
------------- --------------- --------------- ---------- ------ ------------------- -------------------- -----------------------
SUM(INVOICE_KEEPING) SUM(INVOICE_STAMP) SUM(INVOICE_OTHER) SUM(INVOICE_MISR) SUM(INVOICE_INSURANCE) SUM(INVOICE_HAIAH)
-------------------- ------------------ ------------------ ----------------- ---------------------- ------------------
       240007 john                          2        123 sell   23-04-2010 00:00:00 OTC                                     27.5
                 3.4                  6                  4                 0                      2                 10

       240007 john                          2        124 buy    22-04-2010 00:00:00 ORACLE                                  29.6
                 2.4                  6                  4                 0                      2                 10

       240007 john                          2        125 sell   01-01-2010 00:00:00 ORACLE                                  63.5
                 2.4                  6                  4                 7                      2                 10

       240007 john                                                                                                         120.6
                 8.2                 18                 12                 7                      6                 30

       240008 paul                          3        256 sell   19-12-2010 00:00:00 OTC                                     93.5
                 8.4                  6                  4                 0                      2                 10

       240008 paul                          3        266 buy    06-03-2010 00:00:00 CBANK                                   83.2
                 3.4                  6                  3                 0                      2                  9

       240008 paul                          3        322 buy    23-04-2010 00:00:00 CBANK                                   43.4
                 2.4                  3                  4                 0                      2                  3

       240008 paul                          3        423 sell   23-04-2010 00:00:00 OTT                                     24.5
                 2.4                  2                  4                 0                      8                 10

       240008 paul                                                                                                         244.6
                16.6                 17                 15                 0                     14                 32

9 rows selected.

Kind regards
Rob.

Tags: Database

Similar Questions

  • How to get the sum of "(qty*rate) as salesValue 'as TotalSalesValue cust_id agenda?"

    Mr President.

    I have to take the column values from3, or 4 tables and two of them need to be multiplied, then get the sum of this value multiplied by using Group by and order clause.

    as below

    cust_id prod name Qty. rate value totalValue
    01one01500500
    01b024008001300

    How to get there

    Select

    cstmr.cust_id CustId,

    PRDT. Name AutoCAD,

    SL.sal_qty SalQty,

    SL.unit_sal_price UnitSalPrice,

    SL.sal_qty * SL.unit_sal_price as SalVal,

    Sum(SL.sal_qty*SL.unit_sal_price) as TotalSalesValue

    Of

    cstmr customer,

    salesLine sl,

    prdt product

    where

    PRDT.prod_id = sl.prod_id

    Group

    cstmr.cust_id,

    PRDT. Name,

    SL.sal_qty,

    SL.unit_sal_price

    order by

    cstmr.cust_id

    Concerning

    Your expected results include values that are not in your input data - there is no M.BOARD product, for example. This is an adaptation of Manik code that will give you the subtotals for each customer:

    SELECT client_name c.nom,

    product_name p.Name,

    SL.sal_qty,

    SL.unit_sal_price,

    SL.sal_qty * SL.unit_sal_price AS salesvalue,

    CASE

    WHEN ROW_NUMBER () OVER (partition by order of c.cust_id p.prod_id desc, sl.sal_id desc) = 1 THEN

    SUM (sl.sal_qty * sl.unit_sal_price) OVER (PARTITION BY c.cust_id)

    END totals

    FROM customer c INNER JOIN sales s ON s.cust_id = c.cust_id

    INNER JOIN salesline sl ON sl.sal_id = s.sal_id

    INNER JOIN product p ON p.prod_id = sl.prod_id

    ORDER BY c.cust_id, p.prod_id, sl.sal_id

    You could get the grand total of lines by the Union in a second query, or by doing something smart using ROLLUP. But I leave that to you because I think you should at least do some of your own homework.

  • How to get the sum of the first row in the previous row?

    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line. Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Hello

    kamranpathan wrote:
    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line.

    If you do not explicitly give a windowing clause, then you get the default windowing clause you indicated.
    If you want another clause of windowing, ionclude in the analytic function call.

    Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Yes. The correct syntax for "Previous rank" is «PREVIOUS 1»

    ...  ROWS BETWEEN  UNBOUNDED PRECEDING
                AND        1          PRECEDING
    

    For more information, search for "Analytic Functions" in the manual of the SQL language:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm#sthref917

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    You will find the answers better faster if you always provide this information whenever you post a question.

    Published by: Frank Kulash, Sep 17, 2011 17:04
    I just saw Etbin responses.
    As usual, Etbin has a good point. If the column that you are basically cannot be NULL, then it is probably easier to subtract the total current line and use the default windowing clause.
    Even if it can be null, you find may be easier to use this approach.

  • How to get the webservices project customer specific use Oracle.

    I have a Web services project I developed in VS2005 where I use the Oracle.DataAccess.dll provided by Oracle 10 g ODAC to connect to an Oracle 8.1.7.4 database. I add a reference to the dll in the folder c:\oracle\product\10.2.0\client_1\ODP.NET\bin\2.x. I create and publish Web services and checked that Web services are working correctly. I ran into problems when I installed the latest version of the ODAC for Oracle 11, where the webservice Gets the following error ORA-03134 - this version of the server connections are more supported. Based on what I read here and ther panels, it seems that when I installed the ODAC for Oracle 11 he installed a policy file that redirects all calls to use Oracle 11 components data access rather than that I've specified explicitly in my project.

    Is it possible for me to always have the components of Oracle 11 working side by side with Oracle 10 g and forced my project to always use the components of Oracle 10 g?

    Published by: lordharlock on March 3, 2010 07:17

    Hello

    I just did a quick test with binding in an app.config file redirection, and has precidence over policy in the gac file.

    Here's my app.config. I compiled with 2.102.2.20, the app ran with 2.111.7.0, despite the 2.111.7.20 policy in the gac file.

    It will be useful,
    Greg

    
    
      
        
          
            
            
           
          
        
      
    
    
  • How to get the parameter values of a step type custom when I create file and adding a type of step seq

    I use lv 8.5 and teststand 4.0.

    I did a step type custom and recorded at the MyTypes.ini in pallets of type.

    I specified a default module by opening the properties of the custom step of *.ini type window, then I put some values of the parameters.

    T1) when I open teststand and I add the custom step type manaully in seq file, the labview module parameter values are represented.

    But, if to use file (create and add support prototype stage), the labview module parameter values has the default value.

    Using joint file, how to get the setting custom step type values I put in *.ini?

    Q2) each type of step are automatically by name through the use of LoadTypePaletteFilesEx. When I open teststand and I add the custom step type manaully in seq file, the module is loaded automatically. Inside the attachment, I use a prototype of charge and a fixed path where the module labview is to load the labview module.

    Can I load module automatically without using a prototype of charge or how can I get a dynamic path of type step?

    I solved Q1 for myself by using the mapping tab of the parameter within the configuration to the default module window.

    Everyone knows Q2?

    Thank you.

  • How to get the values of page jspx (view layer) to the custom method defined in AM

    Hello

    I have 1 text field and 1 submit to homepage.jspx. When I click the button submit, it will call the custom method defined in the 'Module of the Application' java class (ApplicationModuleImpl.java). Can I know how to get the value of this text field in this custom method.

    I used the getter and setter method, however it didn't work as it is defining the value correctly, but get method returns null. Its not allowing to use FacesContext. Could someone please tell me how to get the value of the text field to this custom method (that is, using ADFContext,... something like that)

    Thanks in advance

    User,
    you have mixed up something here. Bean (as you did) cannot use the module of the application. They belong to different layers.
    I suggest you to look at some first tutorials (http://docs.oracle.com/cd/E18941_01/tutorials/toc.htm) or watch the developer guide http://docs.oracle.com/cd/E16162_01/web.1112/e16182/toc.htm and take a look at some of the videos http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adfinsider-093342.html

    Timo

  • How to get the path of the directory component in custom filter

    How to get the path of the directory component in a custom filter?
    final String absoluteComponentPath = CompInstallUtils.computeAbsoluteComponentLocation( "yourComponentName" );
    
  • How to calculate the sum of two digital form fields based on the selection of the checkbox.

    I have a form in Acrobat Pro who needs a custom calculation. How to calculate the sum of two digital form fields based on a selection of the checkbox. I have three number fields. Field-A and B are simple one or two digits. Field-C is the sum, or the total field. I want to field-C have a control box which, when turned on and off, just gives a. gives the sum of A + B

    _ Field - 2

    _ Field - A 4

    [check] _ _ field - 6 C

    [disabled] _ _ field - 2 C

    Thank you

    The custom field C calculation script could be:

    (function () {
    
        // Get the values of the text fields, as numbers
        var v1 = +getField("A").value;
        var v2 = +getField("B").value;
    
        // Set this field's value based on the state of the check box named "CB"
        if (getField("CB").value !== "Off") {
            event.value = v1 + v2;
        } else {
            event.value = v1;
        }
    
    })();
    

    Replace 'A', 'B', and 'CB' with the real names of the fields.

  • How to get the Subvi (the virtual path is in .exe) reference in Run Time System

    Hello world

    The problem is how to get the reference of the Sub - VI in run time system, when the Subvi is in .exe after construction.

    More details:

    Top of page vi called the Subvi dynamically, so that the Subvi is always included, and the source object is the application.exe.

    After the above configuration, the Sub - VI will be the application.exe. For example, the path of Subvi est...\application.exe\SubVI.vi

    So, how to get the reference of the Subvi in Run Time System?

    I can't do it when you use 'open reference VI' with le...\application.exe\SubVI.vi path in the run time system.

    In fact, I can create a file to include the Subvi, rather than build the Subvi in application.exe, then I can get the convenintly reference. But this isn't my favourate average.

    Thank you

    chenyin

    That is the problem. Call a Subvi dynamic means users could change, but it is also very attractive.

    The dynamic call should be used in a user control, but some parade can avoid problems.

    It depends on why you use dynamic calls...-online 2 main ways:

    -Dynamic call are used to maintain a scalable framework for the code without acting on the executable file-online a single VI distribution managed by the administrator/developer

    -Dynamic call are used to provide a collection of "external" characteristic that could be enriched by the administrator/developer. For example, you provide your customers a set of selectable custom signal filters in the executable.

    In 2 cases, you are only able to assess the skills of the users to know if there is a risk of damage, if there is a change.

    So to stay only master a parade might be to provide dynamic VI without a schema, but with the problem of maintenance, since no in-place editing and more attention to manage distribution.

    Another way is to hide the actual distribution to user-online call dynamic VI but it without name as *.vi but others (a repellent name as system of OS name ) or simply without extension in order to attract not user... but that's debatable...

    Another more difficult but more secure method is to create a consistency check before your routine (version, user, modified date,...)

  • BB10: How to get the response header

    Hi guys,.

    I would like to how to get the response header of a request using a typical QNetworkAccessManager. What I really need, it's to get the server date and I know that the response header there.

    I have seen that you can access some header in the response of the requestFinished() function object. But none of them is the Respone header.

    Does anyone have any idea on this?

    Thanks in advance.

    Hello

    If you have subscribed for over QNetworkManager (QNetworkReply * response) of the signal, use:

    Reply-> rawHeaderList() for a list of all the available headers.

    reply-> header (param) make themselves known headers, but they do not include Date.

    Reply-> rawHeader ("date") for the date or other custom headers.

    http://Qt-project.org/doc/Qt-4.8/qnetworkreply.html#rawHeader

    Returns the raw content of the header headerName such as sent by the remote server. If there is no header, returns an empty byte array, which may be distinguished by a header blank. HasRawHeader () allows to check if the server sent this header field.

  • Getting the list of Custom Component ListView

    Hello

    I'm trying to figure out how to get the 'checked' property of a custom component of QML.

    Basically, it's the same as the first example on https://developer.blackberry.com/cascades/documentation/ui/custom_components/index.html

    This is a list, with a listItemComponents, whose type: "item" contains a check box and the label.

    I have an ActionItem whose job is to take all elements that are enabled and do something.

    The ActionItem triggers a C++ code that should get this list.

    Problem is, I can't figure out how to get the selected items. I tried the selected() function but it returns empty.

    I have to turn this into a multiple selection?

    I got so far is the back of GroupModel, after selection, but this does not include anything other than what I fed in the first place. Which makes sense.

    There are a lot of similarities between this issue and the other. Should help to my code and comments in this post, I think: http://supportforums.blackberry.com/t5/Cascades-Development/LstItemComponent-doesn-t-track-the-model...

  • How to get the last access to the workflow? (OM, WMS) release 11.5.9

    Hello my friends.

    I am looking for information on how to get the date of the access and the user name who did use some WFs in OM and last WMS.

    If it is through the application or running in the background via SQL for the information is not important to me.

    Could you help me with this?.

    Thank you

    the 'item_type' attribute must match the name of the WF?

    Yes (internal name. For example OEOL).

    The custom of those who will not be affected by the upgrade.

    You must run the query that I provided before to identify if the workflow is used or not.

    For the workflow of order lines, it is intended to be used as you use the order management.

    Kind regards

    Bashar

  • How to get the selected row in a programmatic table of the ADF (table generated from a bean)

    Hi all


    We use JDeveloper Studio Edition Version 12.1.3.0.0 and deployed on GlassFish Server Open Source Edition 3.1.2.2 (build 5) and connect to the SQLServer database.


    How to get the selected line in a programmatic (using a SortableModel custom not a display object) ADF table (generated from a bean)?


    We are trying to get the selected row in a bean of a programmatic ADF table to retrieve data based on the selected line.


    Any idea?

    Well, you can use selectionListener to set the selected line to a variable of bean (but this bean must be in extended view or some superiors)

    Something like this: http://www.awasthiashish.com/2015/07/get-selected-row-singlemultiple-from.html

    Dario

  • How to get the balance of an element value

    Hello

    I have a requirement to obtain related information with balance. I am able to read the information on the element except balance.how to get the value of the particular item balance.

    for the application-> transfer and process-> queries with trust-> value the month selected and chosen balances button and queries with the obtained item name break it down the value of the balance.

    These values I want in my query.i tried backend with calling package by passing parameters like the number of transfer, balance the id and date but iam getting value "0".

    IAM new to hrms, Please help me on how to get this balance of values

    Thank you

    Hello

    It is not very clear what you want to display in the form of balance for a given range of dates.

    It depends on how you have configured your balances and periods and balance which you are referring.

    The API allows for a given only date that matches the date earned.

    Say, for example, that you have a "basic salary" defined with a "Treatment period assignment to Date" dimension and feed of the element that corresponds to the base salary.

    "If you need get the 'wage base Total' (balance?) for the period February 1, 2015 ' to March 31, 2015", then you need get dates earned for payroll passes made during that period and call the package above with the appropriate settings.

    Another way is by querying the tables/views directly: you can use, for example - it's perhaps easier to your situation:

    Select sum (nvl (pbv.value, 0))

    of pay_balance_values_v the VB.

    where pbv.balance_name = 'base salary.

    and pbv.database_item_suffix = '_ASG_PTD. '

    and pbv.assignment_id =

    and pbv.effective_date between to_date (' 01/02/2015 ',' dd/mm/yyyy')

    and to_date (' 31/03/2015 ',' dd/mm/yyyy');

    Kind regards
    Rajen

  • How to get the values of the table of the ADF to bean class?

    Hi all

    My 11.1.1.6 Jdev

    Here I do not use BC ADF in my project.  I'll put values in the ADF table with bean.

    In the table, I put a checkbox. When I selected (Checkbox) a few rows in table and submit. In the submit method, I want to get all the values of line checkbox selected in my bean class.

    How can I get the values. ???

    Here my table UI code

    < af:table var = "row" rowBandingInterval = "0" id = "t1" value = "#{pageFlowScope.BinderSolutionsBean.uiBinderProperties} '"

    styleClass = "AFStretchWidth" emptyText = "no record found".

    Binding = "#{pageFlowScope.BinderSolutionsBean.binderTree}" >

    < af:column sortable = "false" headerText = "Script ID" id = 'c4' >

    < af:panelGroupLayout id = "pgl4" >

    < af:selectBooleanCheckbox id = 'sbc1' > < / af:selectBooleanCheckbox >

    < af:spacer width = "5" / >

    < af:outputText value = "#{row.scenarioId}" id = "ot5" / > "

    < / af:panelGroupLayout >

    < / af:column >

    < af:column sortable = "false" headerText = "Quote ID" id = "c1" >

    < af:outputText value = "#{row.quoteId}" id = "ot4" / > "

    < / af:column >

    < af:column sortable = "false" headerText = "NASP ID" id = "c2" >

    < af:outputText value = "#{row.naspId}" id = "ot2" / > "

    < / af:column >

    < af:column sortable = "false" headerText = "GCH ID" id = 'c3' >

    < af:outputText value = "#{row.gchId}" id = "ot3" / > "

    < / af:column >

    < af:column id = "c6" headerText = "Term" >

    < af:outputText value = "#{row.term}" id = "ot9" / > "

    < / af:column >

    < af:column sortable = "false" headerText = "Status" id = "c5" >

    < af:outputText value = "#{row.status}" id = "ot6" / > "

    < / af:column >

    < / af:table >

    follow some above recommendation such as the creation of additional attribute. You will also need the key in your collection, while making the data for your chart.

    You must write a custom selectionListener. On valueChangeEvent of box, get the key of a line and add the line at the bean.

    Maybe it's little help for you

    https://tompeez.WordPress.com/2012/01/22/jdev-custom-SelectionListener-for-viewobjects-in-rangepaging-mode/

    How to get the selected row in a table no-bind ADF

Maybe you are looking for