running-total

Retrieve running-total record growth over time in mysql

陌路散爱 提交于 2019-12-04 13:14:37
I have a Drupal site which has a table that keeps track of users. What I want to do is graph membership growth over time. So I want to massage mysql into returning something like this: date | # of users (total who have registered up to the given date) 1/1/2014 | 0 1/2/2014 | 2 1/3/2014 | 10 Where '# of users' is the total number of users that have registered accounts up to the given date (running-total)--NOT the number of users who registered on that particular day (which is trivial to retrieve). Each row of my {users} table has a uid column, a name column, and a created (timestamp) column. So

Selecting a subset of rows that exceed a percentage of total values

落爺英雄遲暮 提交于 2019-12-04 06:09:51
I have a table with customers, users and revenue similar to below (in reality thousands of records): Customer User Revenue 001 James 500 002 James 750 003 James 450 004 Sarah 100 005 Sarah 500 006 Sarah 150 007 Sarah 600 008 James 150 009 James 100 What I want to do is to return only the highest spending customers that make up 80% of the total revenue for the user. To do this manually I would order James' customers by their revenue, work out the percentage of total and a running total percentage, then only return records up to the point that the running total hits 80%: Customer User Revenue %

Oracle SQL Analytic query - recursive spreadsheet-like running total

不羁岁月 提交于 2019-12-03 04:04:33
问题 I have the following data, composed of the A value, ordered by MM (month). The B column is computed as GREATEST(current value of A + previous value of B, 0) in a spreadsheet-like fashion. How can I compute B using a SQL Query? I tried using Analytic Functions, but I was unable to succeed. I know there is the Model Clause; I found a similar example, but I don't know where to begin. I am using Oracle 10g, therefore I cannot use recursive queries. Here is my test data: MM | A | B -----------+---

In PHP MySQL Sum total nos of rows based on search results

こ雲淡風輕ζ 提交于 2019-12-02 23:02:32
问题 In PHP MySQL , I have made mobile shop system , in which user buy and sell the mobile and amount of buy & sell is inserted in database by form. i am retrieve all the data from table in view and count total no of buy and sell price. also i am seaching based on different parameters like mobile IMEI, Bill no, Model no,etc. but after searching it will show results correctly, but i want to show the mobile price total according to their search. if(isset($_POST['submit'])){ $a = $_POST['userInput'];

Oracle SQL Analytic query - recursive spreadsheet-like running total

时光总嘲笑我的痴心妄想 提交于 2019-12-02 16:24:49
I have the following data, composed of the A value, ordered by MM (month). The B column is computed as GREATEST(current value of A + previous value of B, 0) in a spreadsheet-like fashion. How can I compute B using a SQL Query? I tried using Analytic Functions, but I was unable to succeed. I know there is the Model Clause ; I found a similar example , but I don't know where to begin. I am using Oracle 10g, therefore I cannot use recursive queries. Here is my test data: MM | A | B -----------+--------+------ 2012-01-01 | 800 | 800 2012-02-01 | 1900 | 2700 2012-03-01 | 1750 | 4450 2012-04-01 |

TSQL-2008 SUM(X) OVER (PARTITION … ORDER BY CLAUSE)

折月煮酒 提交于 2019-12-02 13:28:47
问题 I really need to take what I have as a result of a CTE, and calculate the cummulative value of groups of data. The dataset is: PERIOD FT GROUP DEPT VALUE 1 Actual KINDER MATH 200 2 Actual KINDER MATH 363 3 Actual KINDER MATH 366 1 Budget KINDER MATH 457 2 Budget KINDER MATH 60 3 Budget KINDER MATH 158 1 Actual HIGHSCH ENGLISH 456 2 Actual HIGHSCH ENGLISH 745 3 Actual HIGHSCH ENGLISH 125 1 Budget HIGHSCH ENGLISH 364 2 Budget HIGHSCH ENGLISH 158 3 Budget HIGHSCH ENGLISH 200 6 Budget HIGHSCH

Running Total C#

放肆的年华 提交于 2019-12-02 13:02:30
I'm creating a donation application that reads the input in a textbox, converts it to a double. Then using the method operatingCost , it should take that converted double and divide it by 17% (operating fees). Currently in the method, I have the variable dontationBFees coming in and then being divided by 17 and creating a new variable afterFees . Everything is working fine but I need to create a running total that will save all of the donations. It should display the total amount raised for the charity (that is, the total amount donated less all operating costs) for all donations up to that

How to calculate running balance in SQL

…衆ロ難τιáo~ 提交于 2019-12-02 12:45:59
I am using embedded derby database and I want to add running balance column by calculating debit and credit amounts so please tell me solution code and image are also available below (as you can see in image balance total is not accurate) SELECT V_DATE,FLAG,V_NUM,V_NARATION, sum(VDTL.DR_AMOUNT) AS DEBIT, sum(VDTL.CR_AMOUNT) AS CRIDIT, sum(dr_amount)-sum(cr_amount) as total FROM VOUCHARDETAIL AS VDTL INNER JOIN VOUCHARMASTER AS VMST ON VDTL.DTL_NUM =VMST.MST_NUM WHERE (V_DATE BETWEEN '12-03-2017' AND '14-03-2017') AND (FLAG='IV' OR FLAG='BR' OR FLAG='CP' OR FLAG='CR' OR FLAG='JV' OR FLAG='BP')

Partitioned Running Totals in SAS

流过昼夜 提交于 2019-12-02 09:40:52
问题 How can I create a new column for an existing dataset that is the running total of an existing column - partitioned by some identifier? ID | Value | New Value ---|--------|-------------------- 1 | 10 | 10 1 | 5 | 15 = 10 + 5 1 | 3 | 18 = 10 + 5 + 3 2 | 45 | 45 2 | 15 | 60 = 45 + 15 I'm used to accomplishing this in SQL (Oracle) with a simple SUM() OVER() statement, but that syntax is apparently not supported in PROC SQL. If possible, I would like to accomplish this within PROC SQL (I am much

In PHP MySQL Sum total nos of rows based on search results

安稳与你 提交于 2019-12-02 09:31:18
In PHP MySQL , I have made mobile shop system , in which user buy and sell the mobile and amount of buy & sell is inserted in database by form. i am retrieve all the data from table in view and count total no of buy and sell price. also i am seaching based on different parameters like mobile IMEI, Bill no, Model no,etc. but after searching it will show results correctly, but i want to show the mobile price total according to their search. if(isset($_POST['submit'])){ $a = $_POST['userInput']; //user enter text for search $sql = "select * from mobile where mob_bill='$a' or mob_imei='$a' or mob