# Questions tagged [sum]

The 'sum' function which returns the sum of the items in an array.

**-1**

votes

**0**answers

17 views

### Sum up values with join and use value only once

I have a query, where I want to sum up the values of all invoiceposition prices grouped by the customer. Important is in this case, that the invoiceposition must be linked at least to one ...

**0**

votes

**1**answer

29 views

### Grouping / adding similar objects

I am querying SCCM database to check the history of users who logged into a computer.
What I have so far works fine however there is a lot of data and I would like to group them all together. For ...

**0**

votes

**2**answers

18 views

### cumulative sum pandas dataframe with conditions

I would like a cumulative sum with some conditions, the regular cumulative sum is given by column b, however I would like the cumulative sum result in column d which does sth a normal cum sum does not:...

**-5**

votes

**0**answers

36 views

### Sum of largest prime factors [on hold]

First I need prime factorization of the numbers which I gave it in the input.txt file and after I would like to calculate sum of the largest prime numbers from that file to an output file in C.
FILE *...

**14**

votes

**3**answers

322 views

### Why is a `for` loop so much faster to count True values?

I recently answered a question on a sister site which asked for a function that counts all even digits of a number. One of the other answers contained two functions (which turned out to be the fastest,...

**1**

vote

**1**answer

26 views

### How do I sum the same cell from dynamic sheets in another cell in master sheet using vba?

I have a workbook with a master sheet (called Data Total) and then multiple other sheets with data named with by the date of the data (e.g "05.23.19"). I get new data every day, so I add a new sheet ...

**0**

votes

**2**answers

22 views

### how to choose and sum data from excel table automatically

I'm setting up an excel data table that i need to make a monthly statistics from it. how can i automatically choose a characteritic from the table and get all its values sumed up ?
This is a garage ...

**1**

vote

**1**answer

26 views

### Sum columns in a pandas dataframe which contain a string

I am trying to do something relatively simple in summing all columns in a pandas dataframe that contain a certain string. Then making that a new column in the dataframe from the sum. These columns ...

**0**

votes

**2**answers

19 views

### Summing values in dictionary who stores list of tuples

I have a list of tuples named lista and values in this list looks like:
[('A', 1234),('A', 9876),('B',6574),('B',9562), etc]
Next I create defaultdict(list) where I store my tuple and I get:
([('A',...

**0**

votes

**0**answers

30 views

### Sum from third row to last row in column B

I have an error which prevents me to run properly my macro. When I try to run my macro, I have the error message runtime error 1004 application defined or object defined error
I checked my code, the ...

**1**

vote

**2**answers

41 views

### Sum 2 columns, ignore NA, except when both are NA [duplicate]

I try to sum 2 columns with some NA. There are a lot of forum questions like my first question: how to sum and ignore NA, but now I do want it to return NA when both columns have NA in a specific row. ...

**1**

vote

**2**answers

54 views

### how to fix this code so that it can test the integers present next to the character?

Given a string containing alphanumeric characters, calculate the sum of all numbers present in the string.
The problem with my code is that it displays the integers present before the characters, but ...

**1**

vote

**1**answer

29 views

### Sum values until a certain value is reached and then start with the next column

I have to sum some values until it has reached a full number (1.0 or 2.0 or 3.0) in Excel VBA.
I have contracts and the following dataset, since I can simply count only a "full contract" as one, I ...

**0**

votes

**2**answers

31 views

### How to SUM multiple DECODE values?

I have the following decodes in my SELECT case:
DECODE (table_name, 'RECHNUNG', SUM(beleg_betrag_offen) ) as re_be_of,
DECODE (table_name, 'GUTSCHRIFT', SUM(beleg_betrag_offen) ) as gs_be_of,
DECODE (...

**1**

vote

**1**answer

27 views

### Create a new array from values in a loop, then sum all values from new array

I have a form with multiple rows where a user can input numbers and calculate outputs.
I can currently calculate the output of each row - the sub-total. But would like to be able to calculate all sub-...

**0**

votes

**0**answers

28 views

### Summation iterated over a variable length

I have written an optimization problem in pyomo and need a constraint, which contains a summation that has a variable length:
u_i_t[i, t]*T_min_run - sum (tnewnew in (t-T_min_run+1)..t-1) u_i_t[i,...

**1**

vote

**1**answer

23 views

### How to prevent duplicate sum after lookup and unwind mongodb

I have collection torder(set of sales,customers,subtotals and invoices) and tsales (set of sales info, it has 1 or more contacts), then I want to check how many total orders of each customer during ...

**-1**

votes

**0**answers

24 views

### Method to calculate and choose best option [on hold]

I need to create a program that takes in a number of steel bar lengths (10 - 2400 mm). An off the shelf bar, has a default value of 600 mm.
I am not experienced in the use of backtracking methods and ...

**0**

votes

**1**answer

10 views

### How do I sum a list with its previous entries and substitute with new and corrected entries?

I am graphing the internet connection in my apartment, and I have data for upload and download speeds, and time with it aswell. I have a list of data for all these variables, but I need to sum my time ...

**-1**

votes

**2**answers

21 views

### Get Sum of a Specific Column on Editing a Cell in Jtable

I am trying to get the sum of column 4 on typing/editing the value on column 4. Immediately i change the figure i.e as i type on any row of column 4 it should change my sum which i set on a jTextField....

**0**

votes

**1**answer

21 views

### Is O(m+n) the same as (O(max(m,n))?

If I have two variables,say m and n,and my algorithm has time complexity O(m+n),is O(m,n) the same as having O(max(m,n))?If yes,can you explain why?

**0**

votes

**2**answers

22 views

### ruby / merge-sum values from two distincts objects having the same keys

Having the following :
a = { k1: 10, k2: 20 }
b = { k1: 14, k2: 10 }
I'd need to get :
# Not sure if that's the right approach, but broken down in steps :
# c = { k1: a[k1] + b[k1], k2: a[k2] + b[...

**0**

votes

**3**answers

72 views

### Python itertools make combinations with sum

A customer of mine is a company that produces different pieces (in different sizes) of wood floor. They have a problem that when someone buys XXm² in wood floor, they have to box its pieces.
The box ...

**1**

vote

**2**answers

60 views

### SQL SUM TOP 5 values per category then SUM category totals per ID

I'm trying to produce an SQL statement to SUM top 5 values within categories per userID to create an overall total. Is this possible and how do I achieve it? I can sum the top 5 per single category or ...

**0**

votes

**1**answer

36 views

### Printing the sum of rows and columns of 2 arrays

I am absolutely stuck. Any help would be appreciated. The question asks
1.Create two 2-dim arrays/matrices (random numbers, range 1 -500, where 1 and 500 should be declared as class constants). ...

**-5**

votes

**3**answers

55 views

### Sum of an array elements through while loop

I tried to sum the elements of an array through while loop using the following code
def sum(input: Array[Int]): Int = {
var i=0;
while(i<input.length) {
sum=i+input(i);
i=i+1;
}
...

**-8**

votes

**1**answer

50 views

### How can I add up all the Values of a List<Integer> if its a value in a map? [duplicate]

So, basically I have a map that looks like :
Map<String, List<Integer>> map = new HashMap<>();
I also have a method that needs to add up all those values for a certain key:
public ...

**1**

vote

**2**answers

69 views

### Prolog - Keep track of multiple sum counters

So I have a list that looks like this:
[
["p1", "p2", "100", "Storgatan"],
["p1", "p3", "200", "Lillgatan"],
["p2", "p4", "100", "Nygatan"],
["p3", "p4", "50", "Kungsgatan"],
["p4", "...

**-3**

votes

**0**answers

29 views

### How can I add two columns of a dataframe? [duplicate]

I have a data frame called "effect" with two columns "effect_price"and "effect_price_store". I wanted to add a column to the dataframe which adds "effect_price" and the "effect_price_store" rowwise.
...

**0**

votes

**0**answers

18 views

### Sum values in a column based on two criteria [duplicate]

I have this dataframe:
data = pd.DataFrame({
'Date': ['2000-01','2000-01', '2000-01','2000-02','2000-03', '2000-03', '2099-01'],
'Value': [10, 30, 2, 3, 40, 50, 999],
'Name': ['Peter', '...

**-8**

votes

**0**answers

61 views

### numbers that can be expressed as Power Sum Problem [closed]

Numbers within a range that can be expressed as power of two numbers.
Given two integers L and R.
Find the number of perfect powers in the given range [L, R].
A number x is said to be perfect power ...

**2**

votes

**2**answers

53 views

### How to do SUM on array from outside file?

I'm newbie college student for programming studies,
so recently i have task to calculate matrix from outside files for Gauss Jordan Numeric Method, in the txt file i provide has 10 (x) and (y) data, ...

**0**

votes

**0**answers

20 views

### How to sum up values in Solr4.10.3

I installed Solr from CDH which version is 4.10.3-cdh5.13.0.
My job like one sql work like,How to realize by Solr4:
select D,E,sum(A),sum(B) from DOC where C='balabala' group by D , E;
I try this ...

**0**

votes

**1**answer

10 views

### Sum of field with where condition of this field - Influxdb

I want to get the sum of result_code where result_code=0.
What I found is that querying without sum gives me result but adding the aggregation sum() and then I have 0 as a result.
For those who want ...

**-1**

votes

**0**answers

27 views

### C++ const keyword in different way [duplicate]

I'm working on homework and I need to use operators such as sum,subtraction for dates in terms of DD:HH:MM:SS.But teacher told me that I need to define sum operation in that way which is below.I haven'...

**1**

vote

**2**answers

28 views

### Auto sum without need to reenter the resolved numbers list of numbers/int separated by white space

I would like to know how to take a longish list of numbers/int separated by white spaces and work out the total/sum all in a few lines of code.
I have tried adapting ( I am a beginner doing tutorials)...

**0**

votes

**1**answer

33 views

### Understanding a sum formula as a subtotal within a for loop

I found a Code which creates a subtotal within a table. The Formula works fine, but I do not understand the Syntax of the sum Formula for the subtotal, which is:
"=SUM(R" & j & "C:R" & i &...

**2**

votes

**5**answers

52 views

### SUM from different column and from different table and show result in one row of each year

I have two tables named table1 and table2 . I've tried to sum some column but result is showing wrong
I've tried the following mysql query:
SELECT t1.year
, SUM(t1.deposit) TOTALDEPOSIT
,...

**0**

votes

**1**answer

40 views

### Pandas- merging two dataframe by sum the values of columns and index

I want to merge two datasets by indexes and columns.
I want to merge entire dataset
df1 = pd.DataFrame([[1, 0, 0], [0, 2, 0], [0, 0, 3]],columns=[1, 2, 3])
df1
1 2 3
0 1 0 0
1 0 2 ...

**-1**

votes

**2**answers

25 views

### Top 1 result select query

I am getting the below error
"Error Number: 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '1 ...

**0**

votes

**2**answers

43 views

### How to perform SUM of multiple VLOOKUP values by treating N/A values as Zero?

I am trying to SUM multiple vlookup values as below:
Column A contains dates, and not all worksheets contain all dates, meaning that vlookup sometimes returns N/A value which in turns returns a N/A ...

**0**

votes

**1**answer

16 views

### Grouping and sum records in JasperReport

I have a list of records. All records have names, quantities and project names. Records can be duplicate in the list. I wanted to group the records by project name, so I used report group, but I also ...

**0**

votes

**1**answer

24 views

### I need to calculate the revenue of the cars sold on a certain day

I have a JTable and all the rows that it contains represent cars with the columns being certain details. Among those details are price and selling date.
The problem that I have encountered is that I ...

**2**

votes

**1**answer

40 views

### get List from with maximum and minimum sum from (nested List) List of List using Java 8

I was checking these question but it's not answer my question
How to get minimum and maximum value from List of Objects using Java 8
Find maximum, minimum, sum and average of a list in Java 8
My ...

**0**

votes

**1**answer

36 views

### Calculate sum for different data types in Django

I have columns in db called as Price and Qty. Price is the textfield because it requires to be written as $ 12 (for example). While Qty is integer.
But when i run my code. it shows an error
...

**0**

votes

**1**answer

36 views

### Groupby and sum several columns pandas

I am trying to groupby several columns. With one column it is easy, just df.groupby('c1').['c3].sum()
Original dataframe
c1 c2 c3
1 1 2
1 2 12
2 1 87
2 2 12
2 3 ...

**1**

vote

**1**answer

48 views

### Python - Summation of a function implementation

How can I implement the following function in python using numpy:
Where:
X is a numpy matrix (500 * 500)
X` is another numpy matrix (500 * 500)
Wi is a weight vector of dimensionality equal to the ...

**0**

votes

**1**answer

26 views

### SUM function consider NULL on Oracle 12c

I was trying to get the nulls on doing a SUM() function on sql and I figured out that sql now consider nulls, so if a column has a different value and a null value the sum is good calculated. For ...

**1**

vote

**3**answers

37 views

### Totalling Columns by a common suffix in SAS

I have a series of Columns titled Income_2015, Interest 2015, Dividends 2015, Income_2018, Interest 2018, Dividends 2018 etc and want to create total columns for each year.
Is there a way to do this ...

**2**

votes

**3**answers

36 views

### How to calculate the sum of the output of a for loop

I've built a for loop that goes through the values of a list, enters them as keys for two dictionaries and multiplies the 2 key values together.
When you print, it gives each multiplied value on a ...