Sum of two variables by year

Hello

How can I use SQL to a different variable sum the two per year, as for 2010 is totalrevenue 6907 + 19539 = 26446 etc.



DATA_YEAR VALUE NOM_DE_VARIABLE
-------------------------------------------------- ---------------------- ----------------------
CTInternalRevenue 2010 6907
CTInternalRevenue 2011 7315
CTInternalRevenue 2012 7990
CTInternalRevenue 2013 8554
CTInternalRevenue 2014 8976
CTExternalRevenue 2010 19539
CTExternalRevenue 2011 16848
CTExternalRevenue 2012 17176
18567 2013 CTExternalRevenue
CTExternalRevenue 2014 20344


Thank you.

Gian

Hello

To ignore some rows in the table, use a WHERE clause:

SELECT       'TotalRevenue'     AS variable_name
,       data_year
,       SUM (total)          AS total
FROM       app_cfas_v2.app_cfas_calculated_data
WHERE       variable_name     IN ( 'CTInternalRevenue'
                    , 'CTExternalRevenue'
                  )
GROUP BY  data_year
ORDER BY  data_year
;

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.

Tags: Database

Similar Questions

  • Addition of two variables inside xslt

    Hi all

    I try to add two variables inside xslt. The result is written to a target node, but I am getting "Nan" in output.

    Here's my xslt.

    < name of xsl: variable = "Amount1" >
    < xsl: choose >
    < template test ='(po:ID = «Distributeur») and (po:TypeCode = "Text_products_base_price7")' >
    < xsl: value-of select = "po:Amount" / >
    < / xsl: When >
    < / xsl: choose >
    < / xsl: variable >
    < name of xsl: variable = "Amount2" >
    < xsl: choose >
    < template test ='(po:ID = «Distributeur») and (po:TypeCode = 'VAT') ">"
    < xsl: value-of select = "po:Amount" / >
    < / xsl: When >
    < / xsl: choose >
    < / xsl: variable >
    < name of xsl: variable = "Value TotalAmount" select = "$Amount1 + $Amount2" / >
    < customer: priceDistributorUnitInclVAT >
    < xsl: value - of select = "number ($TotalAmount)" / >
    < / client: priceDistributorUnitInclVAT >

    I want to add Amount1 and Amount2 and use it to map it to the target node.

    The entries on the way to the sum in a third variable. ?

    Kind regards
    Vikas

    Hi Vikas,

    You must include xsl: otherwise in your xsl: choose the clause, it seems to me that your state of health one of the variables will be always Nan and a number + Nan will always result in Nan.

    Look at this
    http://w3schools.com/xsl/xsl_choose.asp

    See you soon,.
    Vlad

    It is considered good etiquette to the answerers rewards with points (as "useful" - 5 pts - or 'correct' - 10pts)
    https://forums.Oracle.com/forums/Ann.jspa?annID=893

  • Number of months in two variables

    Hello

    In the procedure with 2 parameters to the format YYYYMM (year and month), I have musto to know how many months there is between two variables, example:

    201112 and 201111 about a month ago
    201112 and 201110 two months ago

    I tried to multiply year by 12 and months in summary and to make a difference, but no job, some body have some idea


    using 9.2.02

    MONTHS_BETWEEN

  • Addition of two Variables

    Hi experts,

    I have only one requirement to sum up the values of the two variables. Can you explain what is the syntax for it. ?

    Thank you..

    If you two xml elements you may have directly as
    If you mean variable xdoxslt, you can summarize their as usual.

  • Need a group of clause for two variables in a table

    I can't find any way to merge the two variables in a group statement with vertical output and horizobtable.
    The statement that I had for a vertical output is (10 gr 2):

    Select to_char (d.begin_interval_time, 'YYYY-MM-DD') as Datenumber,
    w.wait_class as Type,
    round (sum (w.total_waits) / 1024/1024, 0) while "Tot-wait."
    dba_hist_snapshot d, dba_hist_bg_event_summary w
    where d.snap_id = w.snap_id
    To_char (d.begin_interval_time, 'YYYY-MM-DD') group, w.wait_class
    order by to_char (d.begin_interval_time, 'YYYY-MM-DD');

    2010-02-28 system IO 234567
    2010-02-28 user IO 34444
    .
    .
    2010-03-01 system I / 0 773777
    .

    But I wanted to have the following summary output in a SQL:

    User IO system IO Idle commit... and so on
    2010-02-26 3442322 344555 335455 5
    2010-02-27 533222 2233 445455 2334
    2010-02-28 3434444 244444 345555 39
    2010-03-01 34444 55445 3444 534

    Someone has an idea?

    Do you mean that?

    SQL> select to_char(d.begin_interval_time, 'YYYY-MM-DD') as Datenumber,
      2  round(sum(decode(w.wait_class,'Concurrency', w.total_waits/1024/1024, 0)),0) as "Concurrency",
      3  round(sum(decode(w.wait_class,'System I/O', w.total_waits/1024/1024, 0)),0) as "System I/O",
      4  round(sum(decode(w.wait_class,'User I/O', w.total_waits/1024/1024, 0)),0) as "User I/O",
      5  round(sum(decode(w.wait_class,'Configuration', w.total_waits/1024/1024, 0)),0) as "Configuration",
      6  round(sum(decode(w.wait_class,'Other', w.total_waits/1024/1024, 0)),0) as "Other",
      7  round(sum(decode(w.wait_class,'Commit', w.total_waits/1024/1024, 0)),0) as "Commit",
      8  round(sum(decode(w.wait_class,'Idle', w.total_waits/1024/1024, 0)),0) as "Idle"
      9  from dba_hist_snapshot d, dba_hist_bg_event_summary w
     10  where d.snap_id = w.snap_id
     11  group by to_char(d.begin_interval_time, 'YYYY-MM-DD')
     12  order by to_char(d.begin_interval_time, 'YYYY-MM-DD');
    
    DATENUMBER Concurrency System I/O   User I/O Configuration      Other     Commit       Idle
    ---------- ----------- ---------- ---------- ------------- ---------- ---------- ----------
    2010-02-22           1        298          0             0          2          0       2107
    2010-02-23           1        299          0             0          2          0       2114
    2010-02-24           1        300          0             0          2          0       2121
    2010-02-25           1        301          0             0          2          0       2129
    2010-02-26           1        303          0             0          2          0       2136
    2010-02-27           1        304          0             0          2          0       2143
    2010-02-28           1        305          0             0          2          0       2150
    2010-03-01           0        140          0             0          1          0        988
    

    Max
    http://oracleitalia.WordPress.com

  • Date between two variables

    Hello

    I need to create a report, which Date is between the current Date and the current Date of 365 days.

    I create two variables, Current_Date (select to_char (sysdate, ' dd/mm/yyyy') of the double) and
    Current_Date-365 (Select to_char ((sysdate-365), ' mm/dd/yyyy') of double)

    In the Oracle replies I select column Date and Date filter between above two variables, but I get an error message when I run the report.
    If I remove the filter from the report works very well.

    Is there another way to do this?

    Thank you

    Hello user.

    Add a filter for the date field that you want to restrict (we'll call it TIME. DATE_VALUE for the sake of this exercise).

    In the filter, click on "Advanced > convert this SQL filter '.

    Add this line in your filter SQL (replacing the TIME. DATE_VALUE with your date field):

    Time.DATE_VALUE <= current_date="" and="" time.date_value="">= (SQL_TSI_DAY,-365, CURRENT_DATE) TIMESTAMPADD

    This will give you all the records with your date between the current date and a year ago.

    I hope this helps and please assign points if you found it useful!

    Kind regards
    Jason

  • How to plot two variables when neither are expressed in time?

    I know how to trace a variable against time, but how to plot two variables when neither one of them are time against each other. For example if I want to draw Let's force against remote what is the best approach to use?

    Thank you.

    Use an XY Chart. Use context-sensitive help to see the expected data type and refer to the examples. Consider what follows, don't forget to rename the scale labels and name:

  • I have two variables A and B. I mean "if (A or B &gt; 0) event.value = A + B.

    I have two variables A and B. I mean "if (A or B > 0) event.value = A + B.

    You must combine two compare different operations:

    If ((A > 0) |) (B>0)) {

    Event.Value = A + B;

    }

  • Faced with the question all by merging two variable result sets in BPEL 2.0

    I am facing problem while merging the response of the two variables (operations and list of objects) in BPEL 2.0

    My code snippet is as below:

    <assign name="AssignJobList">
      
    <extensionAssignOperation>
      
    <bpelx:copyList>
      
    <bpelx:from>$InvokeJobDetailsPSGetUpdatedJobObjectsResponse.JobProxyResponse/sfabmabo:Job</bpelx:from>
      
    <bpelx:to>$MergeJobListResponseMessage.JobProxyResponse/sfabmabo:Job</bpelx:to>
      
    </bpelx:copyList>
      
    <bpelx:insertAfter>
      
    <bpelx:from>$InvokeJobDetailsPSGetEffectiveJobObjectsResponse.JobProxyResponse/sfabmabo:Job</bpelx:from>
      
    <bpelx:to>$MergeJobListResponseMessage.JobProxyResponse/sfabmabo:Job[last()]  </bpelx:to>
      
    </bpelx:insertAfter>
     
    </extensionAssignOperation>
    </assign>


    For CopyList operation, its updates the target variable but for the insert after operation on its merger nor her raise an error.

    Could you please help me in the same.

    Thank you

    Hello

    The above problem can be solved by adding a tag for each operation of bpelx as shown below:

    $InvokeJobDetailsPSGetUpdatedJobObjectsResponse.JobProxyResponse / sfabmabo:Job

    $MergeJobListResponseMessage.JobProxyResponse / sfabmabo:Job

    $InvokeJobDetailsPSGetEffectiveJobObjectsResponse.JobProxyResponse / sfabmabo:Job

    $MergeJobListResponseMessage.JobProxyResponse / sfabmabo:Job [last ()]

    Kind regards

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

  • Assign the values of the two variables in a select statement

    I'm trying to set two variables in a select statement in my definition of the procedure. I get the error identifier not valid "ATTRIBUTE" running the following code.
    create or replace procedure tbl_auth (
    Email in varchar2,
    UserLevel out number)
    as
      v_Email varchar2(100) := lower(Email);
      v_login_chk number := 0;
    begin
     select UserLevel into p_UserLevel,
            v_login_chk into v_login_chk
     from tbl_User
     where eMail=v_Email  
    
    exception
     when no_data_found then
      UserLevel := 0;
    end tbl_auth;
    Can I not connect two different values to two different variables in the same select?

    Thank you

    Published by: jerry8989 on August 22, 2011 07:06

    Published by: jerry8989 on August 22, 2011 07:06

    change as follows:

     select UserLevel, v_login_chk into p_UserLevel,
            v_login_chk
    

    IN ONE ALONE is enough.

    BTW, don't you have "login Check" column in the "tbl_user"? If you do, your selection should be like this:

    ...
    select UserLevel, loginChk into /* check the column name in your table */
             p_UserLevel, v_login_chk
     from tbl_User
    ...
    
  • Problem comparing two variables to help assess variable

    Hello
    IAM using 10.1.3.3 designer ODI where in I have a case to compare two variables.
    IAM using evaluate variable for it as Var1 = #Var2
    My case is as below
    If
    Var1 = Var2
    flow goes to xxx
    on the other
    flow goes to yyy

    I was faced with number format exception when I stated as digital variables. I changed to alpha numeric and tried again. This time the exception has disappeared, but the comparison happens as expected. I have the variables satisfying the real condition (var1 = var2 = 1234). But still the flow occurs for the condition false, which indicates that the comparison goes as planned. My DB is oracle.
    Any suggestions on this are appreciated.
    Thank you
    Naveen.

    Published by: 798664 on November 9, 2010 02:24

    Project you drag and drop your var1 and var2 in refreshing fashion
    Now do drag var1 in evaluation mode and make the comparison

    It must also include the code in your project.

    That is to say var1 = #. Var2
    then implement your business logic

    Thank you
    Fati

  • with regard to the exchange of two variables

    I have two variables of type varchar2. I need to exchange them using a procedure which takes two variables as arguments and returns them exchanged.
    can someone give me the procedure complete pl - sql for the same thing.
    I'm new to pl sql.

    Thank you.

    Published by: user12773921 on March 9, 2010 08:48

    Published by: user12773921 on March 9, 2010 08:50

    Hello

    You can use variables in the end.

    create or replace the swap procedure (IN OUT VARCHAR2 var1, var2 IN OUT varchar2) as
    Temp varchar2 (100);

    Start
    Temp: = var1;
    var1: = var2;
    var2: = temp;
    end;
    To check the output, I stated an anonymous pl/sql block

    declare
    VARCHAR2 (100) var1;
    VARCHAR2 (100) var2;

    Start
    var1: = 'A ';
    var2: = 'B ';.
    dbms_output.put_line (' before swap var1:' | var1);
    dbms_output.put_line (' before swap var2:' | var2);
    dbms_output.put_line ('swapping');
    swap (var1, var2);
    dbms_output.put_line (' after swap var1:' | var1);
    dbms_output.put_line (' after swap var2:' | var2);
    end;

    Published by: user8962436 on March 9, 2010 11:08

  • sum on two dimensional

    Hi all, I'm fine with excel, but have trouble extrapolating numbers for this and hoping that someone can help.

    Basically, for example, a spreadsheet to budget domestic.  I have a table of data where column A is the month of the entry, column B is the category, and column C is the $.  Something like:

    A         B                   C

    April 1 grocery store $100

    2 April gas $50

    grocery store $75 April 3

    May 4 utilities $50

    grocery store $90 may 5

    May 6 gas $40

    (imagine the above, but with several months of data).

    I want to create a summary table summarizing the totals by month and category

    A                   B                C

    April may

    Food products 1 175-$ 90

    2    Gas                $50             $40

    3 utilities $0 $ 50

    That means, in B1, the sum of $ is the $ total for all groceries in April entries in the table above ($100 + $75).

    My excel formulas do not seem to be transferred on the well, when I try to build it.  Any ideas?  What is quite a unique use of SUMPRODUCT in numbers or something else?

    Thanks for the thoughts that you all.

    See you soon,.
    Aaron

    The numbers do not support forms of 'matrix formula' of SUMPRODUCT.  Use rather SUMIFS (which also works well in Excel).

    The formula in B2, filled with worms the down and right, is:

    = SUMIFS(Data::$C,Data::$A,B$1,Data::$B,$a2)

    Be sure to type a "before names so that the numbers treated as text and you will get a match."  Otherwise, it will guess that you mean a date and time string (which will match this year, but not for the entries of entry next year).

    SG

  • Satellite C650-15IL - international guarantee two or one year?

    Hello

    I bought laptop Satellite C650-15IL in Israel.
    The dealer promissed 2 years warranty and 2 years international warranty appears in the description of the product:
    http://IL.computers.Toshiba-Europe.com/innovation/en/series/satellite-C650-series/1084942/

    However, when I registered my laptop on this site, I received an email indicating that I have "Standard warranty Toshiba" that usually indicates a year only in Europe and Middle East.

    I'm going to study in Boston, in the United States in the coming years and international warranty means a lot to me and it is one of the main reasons I chose toshiba.

    Anyone can wipe it out, how long is the warranty and is truly 'International' or is it only good for Europe?

    Thanx

    Hello

    Toshiba Standard warranty the laptop just for one year.
    But AFAIK you can extend it for a further year if you register the notebook on page Europe from Toshiba.

    I put t know exactly in the terms of warranty in your country, but in Germany for example, each product is covered by warranty dealer for two years.

    Welcome them

Maybe you are looking for

  • Inbox Gmail takes to always appear entirely in Mac Mail

    I'm a long-time Gmail user. I have Mac Mail 9.3 (3124) and use several different servers IMAP e-mail with ease. Gmail, not so much. When I go on my Gmail inbox, often only the last element displayed, apparently forever, and that happens when I share

  • Satellite U940 PSU6VA - recover after removing the software RAID

    * My specifications: *.* Model: * Toshiba Ultrabook (Satellite PSU6VA - 00S 002 U940)* Operating system: * Windows 8.1 x 64 (upgrade of Windows 8 x 64)* Storage: * 500 GB + SSD 30 GB HARD drive This particular model of Toshiba comes with two hard dri

  • a pop up telling me to re activate windows

    I get a pop up telling me to re activate my copy of windows, but it has been activated for about 6 years I have to do this or is it a scam

  • HP deskjet 6940 driver windows 7

    I have a job perfectly HP DeskJet 6940 but my SSD has failed and I need to reinstall the drivers for win 7 64 bit.  A year ago, they were still in line with instructions for installation.  Now the only driver is for a USB printer.  I don't remember h

  • Period of Continous Pings VPN

    Thanks in advance. I have an ASA5505 to a remote location and an ASA5550 to my loocation... I get the following info in my logs: IP = 62.73.210.70, invalid header, lack of payload SA! (next payload = 4) Group = 62.73.210.70, IP = 62.73.210.70, no pre