Running total

Data in the table:


Select 1 id, date ' 2008-01-16' date_created, 5 sales, the name of "Bob" Union double all the
Select 2 id, date ' 2008-01-16' date_created, 2 sales, name 'abc' of all the double union
Select 3 id, date ' 2008-02-16' date_created, 4 sales, the name of "Bob" Union double all the
Select 4 id, date ' 2008-02-16' date_created, 3 sales, "xyz" name all the double union

I need output below mentioned format.


Date_Created name Total_cumulative_sales

2008-01-16 bob 5
2008-01-16 abc 2
2008-02-16 bob 9
XYZ 2008-02-16 3
2008-02-16 abc 2

So I * think * you need a cumulative amount including all day from which a sale of products is available without worrying if a product has been sold to date or not... so something like:

WITH sample_data AS

(SELECT 1 ID, DATE ' 2008-01-16' date_created, 5 sales, "Bob" NAME OF double UNION ALL)

2 SELECT ID, DATE ' 2008-01-16' date_created, sales 2, 'abc' NAME OF double UNION ALL

3 SELECT ID, DATE ' 2008-02-16' date_created, 4 sales, "Bob" NAME OF double UNION ALL

SELECT 4 id, DATE ' 2008-02-16' date_created, 3 sales, "xyz" name OF double

)

all_dates AS (SELECT DISTINCT FROM sample_data date_created)

SELECT *.

FROM (SELECT ad.date_created

sd.NAME

, SUM (sd.sales) OVER (PARTITION BY sd.NAME ORDER BY ad.date_created, sd.ID) cumulative_sales

From all_dates ad

LEFT OUTER JOIN sample_data sd PARTITION BY (sd.NAME) ON (sd.date_created = ad.date_created))

WHERE cumulative_sales IS NOT NULL

ORDER BY date_created, name;

HTH

Tags: Database

Similar Questions

  • Apple Watch keeps a running total?

    I do not like the brand "Fitbit" because they have reset every day.  Apple Watch maintains a 'running total' miles I have finished or does it reset every day like the Fitbit?

    Hello

    The total distance is reset every day within the activity app.

    More information:

    Use the activity on your Apple Watch - Apple Support

  • Question 'Running Total' account

    I have a request where an account is needed to keep a "running total".  I don't think that balancing time will work.  Requirement is the account would be just more each month, then Jan of second year is equivalent to decrease on the first year and so on...  DTS handles this?  Not quite sure DTS continues to run tally forever...

    Thanks for any input.

    DTS only works during the year.  Create an account that will take its previous value and add the month.  For January, you will need to look back at previous December.  You probably need a stored value, otherwise, it will recalculate the history whenever it is used.

  • Schedule running Total

    Hi experts,

    Need your expert helping hand for one of the reports that I am currently working.
    This report runs every hours 12:00, 13:00... so now and the requirement is to produce hourly running Total of Stock_Shortages.

    From now on, I had an obligation to produce just the hourly figures for which I used the following query

    SELECT
    TO_CHAR (SALES_ORDER_HEADER. SOH_DATE_RELEASED, ' dd/mm/yyyy') as RELEASED_DATE,
    substr (to_char (SALES_ORDER_HEADER. (SOH_TIME_RELEASED, "HH24:MI:SS"), 1, 2) as RELEASED_TIME,
    SOH_CLASS as a CLASS,
    County (SALES_ORDER_HEADER. SOH_ORDER_NO) as Stock_Shortage
    Of
    COM SALES_ORDER_HEADER SALES_ORDER_HEADER
    WHERE
    SOH_STATUS = ' 05 "
    AND SOH_DATE_RELEASED = TRUNC (SYSDATE)
    AND substr (to_char (SALES_ORDER_HEADER. (SOH_TIME_RELEASED, "HH24:MI:SS"), 1, 2) < substr (to_char(sysdate,'HH24:MI:SS'), 1, 2)
    GROUP BY
    TO_CHAR (SALES_ORDER_HEADER. SOH_DATE_RELEASED, ' dd/mm/yyyy'),
    substr (to_char (SALES_ORDER_HEADER. (SOH_TIME_RELEASED, "HH24:MI:SS"), 1, 2).

    How can I change this query to display a running total of the Stock_Shortage at the end of each hour?

    Plssss help...

    post some sample data (INSERT INTO...)

    with CREATE TABLE...

    It must be addressed using the analytical functions, something like

    SUM(stock_shortage) over (order by trunc (datecol, 'hh'))
    
  • How do the running total?

    Hi, I want to make a graph that shows a number cumulatively. For example, from month 1, we have 100 accounts. In 2 months, we add 10 new accounts, so we have 110 account cumulatively, so on. Can you tell me how to get the running total?

    If you put the data in a PivotTable and put your value in the measurement section. When you select the area additional options, you can select view as the running sum.

    see you soon
    Alex

  • Running total - analytic function

    I wanted to get the running total for yr_total column based on acc_num, month, year, month_total
    
       ACC_NUM      MONTH       YEAR MONTH_TOTAL YEAR_TOTAL
    ---------- ---------- ---------- ----------- ----------
             1          1       2008          10     10
             1          2       2008          12     22
             1          3       2008           0     22
             1          4       2008          11     33
             2          1       2008          20     20 
             2          2       2008          10     30
             2          3       2008          10     40
             2          4       2008           0     40
             2          5       2008           0     40
             3          1       2008          20     20 
             3          2       2008          10     30
             3          3       2008          10     40
             3          4       2008           0     40
             3          5       2008          20     60
             

    Look at the second post Rob, you need a dummy WHEN NOT APPARIES:

    when not matched then
    insert (acc_num) values (null)
    

    Add at the end of the merger.

  • How can I run totally sperate VI of a compiled application

    Hi, I have hit a wall here and don't know what direction I should be moving in.  A relevant detail, LV8.2 running and Vista/XP application builder.  Any suggestions on the approach I should take would be more useful.

    I have a top-level application (compiled into the application Builder) from there I want to run other VI which are found elsewhere in my file system of the local network.  If the top-level application gives the user a standard interface, where they can then run the other VI which are specific tasks (but this detail is not serious for the user).

    Over time I will add more task-oriented of the vi system and I want to avoid having to be part of these vi of the high-level application-oriented tasks as the maintenance will be more painful.  The opportunity to correct or add a new individual task oriented VI without having to recompile the entire application of high level is the goal.

    On top of that I need to move some info to the VI-oriented task and get some information back from it.

    Some points that I can't get my head at this point are-

    1. the task oriented VI - I need to compile these with the application builder or can I call a VI not compiled and run in the top-level application (I do not)?

    2. How do I call the VI of the top-level application-oriented task - I looked 'Reference VI open' and "Open Application references" and don't know how they apply to this situation.

    Any thoughts would be appreciated, if not, I'm stuck with a lot of trial and error time consuming to understand this.

    Thank you very much.

    Hi guru,.

    had to download a trial from LV to look at your work (always on LV8.2 ).  I can see how it's done.  Very well.  It is along a line, I thought, but there are obviously some details that would have taken some time to get on top of.  Thank you very much for tire him to point me in the right direction, I'm going to use this approach.

    Herbert

  • Monitoring of VPN - running Total

    Hello

    I was wondering what is the meaning of the Total cumulative number means?  I guess it's just the total amount of connection which took place up to this point and does not affect the total number of allowed simultaneous connections?

    Thank you.

    Hi Max,.

    The cumulative is simply a number of Ipsec firewall connections recorded since is online.  This has no effect on the number of counterparts Ipsec or VPN simultaneous connections the ASA can manage.  Cumulative are just statistical database on all of your SSL/VPN, etc... saved connections.

    These statistics can be eliminated by clear statistics of vpn-sessiondb in global configuration, or mode when the firewall is reloading.

    Kind regards

    Jorge

  • SELECT LINES FROM TOP TO BOTTOM UNTIL RUNNING TOTAL = SOME_VALUE

    In the example below, I will select rows from top until my cumulative total of PAYAMOUNT is less than or equal to 40000

    ID RATE DATE ORGAMNT PAYAMOUNT

    1 3.23 12/12/12 23000,45 13000.00

    2 4.55 30/05/11 40000,55 26000.00

    3 6.78 21/03/14 60000,00 60000.00

    My output table must be

    ID RATE DATE ORGAMNT PAYAMOUNT

    1 3.23 12/12/12 23000,45 13000.00

    2 4.55 30/05/11 40000,55 26000.00

    Appreciate your help.

    Kind regards.

    Hello

    This sounds like a job for the analytical SUM function.

    As you post CREATE TABLE and INSERT statements for your data, I will illustrate using the table scott.emp, which is probably on your system.

    Scott.EMP contains the ename, hiredate and sal columns below:

    ENAME HIREDATE RUNNING_TOTAL SAL

    ---------- ----------- ---------- -------------

    SMITH, 17 December 1980 800 800

    ALLEN 20 February 1981-1600-2400

    February 22, 1981 DISTRICT 1250 3650

    JONES, 2 April 1981 2975 6625

    May 1, 1981 BLAKE 2850 9475

    CLARK 9 June 1981 2450 11925

    13425 1500 08 - Sep - 1981 TURNER

    MARTIN 28-Sep-1981 1250 14675

    5000 17 November 1981 KING 19675

    JAMES 3 December 1981 950 23625

    FORD 3000 3 December 1981 23625

    MILLER, January 23, 1982 1300 24925

    SCOTT on April 19, 1987 3000 27925

    ADAMS, 23 May 1987 1100 29025

    Now, let's say, we want to show that the first lines (in order by hiredate) where the total sal is not more than 10000.  One way to do that would be to use the SUM function to calculate the running_total above column and use running_total in a WHERE clause, the results below:

    ENAME SAL HIREDATE

    ---------- ----------- ----------

    SMITH, 17 December 1980 800

    ALLEN 20 February 1981 1600

    DISTRICT 1250 22 February 1981

    JONES, 2 April 1981 2975

    May 1, 1981 BLAKE 2850

    Here's a way to do it:

    WITH got_running_total AS

    (

    SELECT ename, hiredate, sal

    SUM (sal) over (ORDER BY hiredate) AS running_total

    FROM scott.emp

    )

    SELECT ename, hiredate, sal

    OF got_running_total

    WHERE running_total<=>

    ORDER BY hiredate

    ;

    The subquery is necessary because the analytic functions are calculated after the WHERE clause has been applied.  If we want to use the results of an analytic function in a WHERE clause, you must calculate the function in a subquery (as got_running_total, above).

  • Running Total and partial in the tables in the ADF

    Hi, I use Jdeveloper 11.1.2.3.0...

    Please I just discovered the ADF table subtotal and total function in oracle Docs, but it does not specify the steps on how to do this... Im not a pro, so please if anyone has a link or a link to a tutorial or can tell me the steps to take in order to accomplish the subtotal and total in my table from the ADF, I'll be very grateful.

    I await your response.
    Thank you

    OBYYS

    http://www.techartifact.com/blogs/2012/11/ADF-Groovy-for-total-sum-of-a-column-in-a-table.html

  • Running Total Grand Total of the columns of the report BEEP

    Hello

    I was getting NaN on my totals using the set_variable/get_variable below:
    <? xdoxslt:set_variable ($_XDOCTX, 'VAR1', sum (ssGroup))? >

    <? xdoxslt:get_variable($_XDOCTX,_'VAR1')? >

    I also need help on getting my corrected where grouping the following grouping:

    ssOwnedBy
    -ssImageType

    It must be grouped by ssOwnedBy then ssImageType and Totaled by ssOwnedBy and a Grand Total at the bottom.
    But the problem is that the ssImageType shows several lines, where it should appear only once shown below:

    FULLTEST < ssOwnedBy >
    -Claim 1 2 1
    -ME 2 1 3 package
    -2 1 3 passive patient
    Total 5 4 7

    DCA0970 < ssOwnedBy >
    -ME 1 3 2 package
    1 3 2-total

    Grand Total 6 7 9

    Can someone please?

    Thank you

    Can you send me the template RTF and xml to [email protected]? I can take a look and try to help.

    Thank you
    BIPuser

  • Running totals of calculation when adding pages

    http://www.funkylogic.co.UK/equity.PDF

    In a nutshell what I want to achieve is the following: a cleint can own several properties and have different percentages on each. Each property has another page of questions (the PDF above is this page). The first part of the equation is to calculate the total of the equity in the property (TotEquity) upwards and then by the percentage holding (TotInterest), work on the participation of people for this property (TotalB). The form has the option to tell us another property (addInstance), and then we have a second page with its own calculations and a new TotalB. This TotalB would become a total race for all pages added. Please can someone help?


    Hello

    Here is a version of the form: https://acrobat.com/#d=b * 01ko6g2gn8Jqns9D1Hhg

    It shows how to loop through the instances of Page1. It doesn't seem to work properly (by me anyway). I'm not convinced the multiplication of two values in the script.

    If all goes well, it will give you a direction.

    A number of things: I am not inclined to name with a big 'P' pages (Master pages are "Page1"), I tend to pages design name as "page1". The font you use adds to the size of the file. Something like Myriad Pro is much smaller.

    Niall

  • hierarchical running totals

    Hello

    I have problems with a hierarchical query producing cumulative totals that I'd appreciate some tips with.

    I have two tables: orders and regions
    In the Orders table, I store the amount of the order and the geographical region including the product id has been ordered.
    Across the table, I have a list of regions, each with its own area id and also the id of the parent area.

    An example of the regions would be:
    Parent area id - region - region ID
    1 - Europe-
    2 - North America-
    3 UK - 1
    4 - country of Wales - 3
    5 - Cardiff - 4
    6 - Swansea - 4

    Orders can be taken at any one of these regional level, so you can have orders directly related to Cardiff and directly related to Wales. Each order can only be connected directly to a region.

    What I would like to produce is some codes sql which shows the total operation for each region.

    So for areas above the order total value of Wales would contain the sum of all orders directly related to Wales + the sum of all orders directly associated with Cardiff and Swansea.

    Any help would be greatly appreciated.

    Thank you

    Sorry made a stupid mistake:

    select region_name, sum(order_amount) order_amount  from
         (select r.region_name, o.order_amount
          from (select connect_by_root r.region_name region_name, region_id
                  from regions r
                  connect by prior r.region_id = r.parent_region_id) r
                , orders o
         where r.region_id = o.region_id)
    group by region_name
    
  • Running totals...

    I'm not quite the most seasoned, but working with CF for about 5 years and can usually get to do what I want.  I thought it would be relatively easy (and prob is you) to add cumulative costs in the output right to a type of review column, but it launched my butt long enough... No.

    Just cumulative costs sum of selected items, in the sort order. I tried different ways to get it to add and view as I need, dbqueries, index of the loop, using calculations of recordcount/currentrow, etc, etc... no joy

    Enjoy your time... really!

    < form...... Select etc >

    < cfquery name = "getcosts" datasource = "xxx" >

    SELECT *.

    Costs

    ORDER by ' #form.sortby # '.

    < / cfquery >

    < cfoutput query = "getcosts" >

    * shows the columns for #item_name # #item_cost # and cumulative cost * based on the sort order of output

    < / cfquery >

    Thank you, IE, that put me close enough to the ballpark, I've been able to solve.  In order to obtain the sum accumulated, just had to cfloop what you put on it.  Think that I was just trying to make it too hard!

    #item_name #, #item_cost #, #runningTotal #.

  • Running on total cumulative

    Hi all. I'm new to Mac and don't have only recently begun to dabble with Mac numbers.
    Currently, I am doing a rudimentary spreadsheet for my payments of gas with a small set of data wide in two columns. A column would represent each payment that I do, and then I want the second column is a running total of all payments I made at this point of data overall.

    So for example, I would like an equation that would add in the running total in the right column, so that each time I added a digit amounts, it would automatically calculate the total on this point in the adjacent cell.

    Is there someone who can help me out here?

    See you soon!

    Hi PaxSoprana,

    You can do something like this:

    C2 = 20 I have copy/pasted this fair value of B2 GE things started.

    C3 = B3 + C2

    This formula is filled down the yellow filling haddle USINT that appears when you hover over the selected cell.

    Quinn

Maybe you are looking for

  • Why do I get BBC for headlines?

    When I click on the menu bar to 'latest news' all that I get is BBC. How do WE headlines?

  • What is the update to the carrier settings?

    Now that I've updated my iPhone to iOS 9.3 6s (13E234) I keep getting popup windows saying "the new settings to update the carrier settings are available. You want to update now? "Never met before. I'd be suspicious of this or go for it?   Thank you.

  • Impossible to activate WiFi on Toshiba NB100 - 11G

    Hello I try to activate wi - fi on nb100-11 g. I activate WiFi fn - F1, and the indicator down is light with an orange color.But it seems that wi - fi is not enabled, even if bluetooth is enabled. So I try to turn on wi - fi through Control Panel, bu

  • Email delivery delay

    I sent an email and 12 hours later, I get a message that it has been delayed, how will I know when he sends actually?

  • defrag and chkdsk __will works is not due to a disk volume error__

    Hello. Windows xp home edition. Defrag works is not due to an error of volume and chkdsk is scheduled, but does not. restore only has a point in there for some reason any and tried, but will not fix the problem. ran chkdsk only, would not end because