Using LINQ to SQL, I have an Order class with a collection of OrderDetails. The Order Details has a property called LineTotal which gets Qnty x ItemPrice.
I know how to do a new LINQ query of the database to find the order total, but as I already have the collection of OrderDetails from the DB, is there a simple method to return the s...

I have two tables, one stores the products and quantity we have bought, the other stores the sells. The current stock is therefore the sum of all the quantity columns in the bought table minus the number of rows in the sells table. How can this be expressed in MySQL. Remember that there are many different products.
EDIT:
To make it hard...

I have a list of stores, departments within the stores, and sales for each department, like so (created using max(sales) in a subquery, but that's not terribly important here I don't think):
toronto baskets 500
vancouver baskets 350
halifax baskets 100
toronto noodles 275
vancouver noodles 390
halifax noodles 120
halifax ...

I'm having a bit of a problem with converting the result of a MySQL query to a Java class when using SUM.
When performing a simple SUM in MySQL
SELECT SUM(price) FROM cakes WHERE ingredient = 'chocolate';
with price being an integer, it appears that the SUM sometimes returns a string and sometimes an integer, depending on the version...

I have a problem related to the subset sum problem and am wondering if the differences make it easier, i.e. solvable in a reasonable amount of time.
Given a value V, a set size L, and a sequence of numbers [1,N] S, how many size L subsets of S sum to less than V?
This is different than the subset sum problem in three ways:
I care h...

How can i convert this to a decimal in SQL? Below is the equation and i get the answer as 78 (integer) but the real answer is 78.6 (with a decimal) so i need to show this as otherwise the report wopnt tally up to 100%
(100 * [TotalVisit1]/[TotalVisits]) AS Visit1percent
...

Hello. I am using MySQL and PHP. I have a table that contains the columns id and quantity. I would like to retrieve the id of the row that is the last to sum quantity as it reaches the number 40 at sum. To be more specific. I have 3 rows in the database. One with quantity 10, one with quantity 30 and one with quantity 20. So if I sum the...

Hi all,
I have a table like this (Oracle, 10)
Account Bookdate Amount
1 20080101 100
1 20080102 101
2 20080102 200
1 20080103 -200
...
What I need is new table grouped by Account order by Account asc and Bookdate asc with a running total field, like this:
Acc...

Hi,
I'm looking for an algorithm which can take two sets of integers (both positive and negative) and find subsets within each that have the same sum.
The problem is similar to the subset sum problem:
http://en.wikipedia.org/wiki/Subset-sum_problem
except that I'm looking for subsets on both sides.
Here's an example:
List A {4, 5, 9,...

Hi,
Anyone knows how to get sum of number?
For example i have mysql column name package.
Package
3
4
1
3
4
If package 3, the value should be usd 5, if package 4, value should be usd 10, if package 1, value should be usd 1 and so on.
So the total value above should be => 5 + 10 + 1 + 5 + 10 = 31
So how do i get sum of it in php?
i...

Hi, I'm sure this is a very simple question! I have a Java method in which I'm summing a set of numbers. However, I want any negatives numbers to be treated as positives. So (1)+(2)+(1)+(-1) should equal 5. I'm sure there is very easy way of doing this - I just don't know how!! Any tips would be much appreciated.
...

Hi all,
1st of all: I'm not a programmer, never learnt programming/algorithms.
Actually I have to program, mostly in awk, or ruby, some bash.
In today's task, I have a huge data set (float numbers) in a plain text file, one record/line, and a sum of all numbers of the set, but the sum is wrong, because some of the numbers (can be only...

Hi,
I'm looking for a way to generate combinations of objects ordered by a single attribute. I don't think lexicographical order is what I'm looking for... I'll try to give an example. Let's say I have a list of objects A,B,C,D with the attribute values I want to order by being 3,3,2,1. This gives A3, B3, C2, D1 objects. Now I want to g...

I'm just started to read up on LINQ and I want to start incorporating it into my code. I know how to compute the sum of a DataTable's column by either "Foreach"-ing through the rows or by doing a compute.sum on the specific column. How do I do the equivalent with LINQ to DataSet?
...

Hello everyone,
I am stuck with a problem which seems stupid but I cannot find out the solution... With XLST, I need to sum a list of values calculated by a template. So I stored these values in a tree structure (a list of "Number" elements contained in a root element "Numbers"). But whatever I try to do with this self-made list, it wil...

I need to add a row dynamically in SQL after the Marketer number changes with the header "Marketer Total" that should add only the "Total" column. For example, after the last row of Marketer 22 row, there should be "Marketer Total" and then under the Total column should be 1804. The same should occur after the last row of Marketer 500....

I have a report and a datasource where one of the columns are of type TimeSpan. The TimeSpan value appears to display correctly in the report when I use Fields!TheTime.Value, no problem there.
07:02:00
05:41:00
But I would like to do a Sum on those values to get the total time of a group. In C# and such I can of course do a TimeSpan ...

I have an integer collection. I need to get all possibilites that sum of values are equal to X.
I need something like this.
It can be written in: delphi, c#, php, RoR, python, cobol, vb, vb.net
...

Hello. I know there are a few post out here about selecting records until a certain number is met from the sum of one field but there isn't any that suits me. I'm using PHP and MySQL.
I have a table named quantity. Inside there are records of product name, product price and product quantity. Besides these, there are a few others that he...

EDIT: Thanks all of you. Python solution worked lightning-fast :)
I have a file that looks like this:
132,658,165,3216,8,798,651
but it's MUCH larger (~ 600 kB). There are no newlines, except one at the end of file.
And now, I have to sum all values that are there. I expect the final result to be quite big, but if I'd sum it in C++,...