sum

How to use sum() within a group_concat() ?

Question revised Really wanted a group_concat of sums... Table: shops +---------+--------+--------+ | shop_id | name | state | +---------+--------+--------+ | 0 | shop 0 | 5 | | 1 | shop 1 | 5 | | 2 | shop 2 | 5 | | 3 | shop 3 | 2 | +---------+--------+--------+ Table: items +---------...

Subsums in SQL Server 2000

Is there any nice way to get subsums in one query for data like this in sql server 2000? Input: Date Value 2008-06-20 10 2008-08-20 20 2008-10-05 5 2008-10-09 30 Desired output: 10 --sum of 1st value 30 --sum of 1st and 2nd values.. 35 65 ...

How to return row of sum()s

I now find my original table structure was not good, so want to change it. But I am having a hard time designing queries to obtain totals in rows with the new structure. current structure: +----------+-------+-------+-------+-------+ | state | shop | item0 | item1 | item2 | +----------+-------+-------+-------+-------+ | 5 | ...

Linq to SQL equivalent of SUM GROUP BY SQL statement

Hi everybody! I'm having a hard time figuring out how to translate this simple SQL statement to (c#) linq to SQL : SELECT table1.vat, SUM(table1.QTY * table2.FLG01 + table1.QTY * table2.FLG04) FROM table1 inner join table2 on table2.key= table1.key where '2010-02-01' <= table1.trndate and table1.trndate <= '2010-02-28' Group by ta...

Crystal Reports: Is it possible to sum for more than one column?

I work on an accounting project in .NET. I want to sum all transaction and its opening balances. I use summary but it Allows only one column.. ...

Select highest total amount in different tables (Access)

Hi I have 2 tables: "sales" and "services". Both tables have these fields: customer and amount I need to retrieve the customer with the highest total amount (sum all amounts), between dates., in the both tables. Example: sales Mary | $100 John | $200 Mary | $200 services Mary | $40 John | $300 If we...

Creating an excel macro to sum lines with duplicate values

I need a macro to look at the list of data below, provide a number of instances it appears and sum the value of each of them. I know a pivot table or series of forumlas could work but i'm doing this for a coworker and it has to be a 'one click here' kinda deal. The data is as follows. A B Smith 200.00 Dean 100.00 Smith 1...

SQL: SUM and GROUP BY don't return any row on ASP

I have two tables as follow: t_product p_id, p_name... t_order o_id, o_product, o_quantity that is my query: SELECT t_product.*, t_order.* FROM t_product JOIN t_order ON p_id = o_product ORDER BY o_product it return: p_id | p_name | o_quantity --------------------------------- 01 | prod_01 | 30 01 | prod_...

Undefined method error on .sum

Hi Guys, I have a error that I can't find the solution. When I run: Week.find(1).results.sum('box') A get a SUM of column box an it works perfect! But when I apply a filter in it: Week.find(1).results.find(:all, :joins => [:seller],:conditions => ['sellers.user_id = ?', 1]).sum('caixas') I get a error NoMethodError: undefined me...

Using multiple JOINS. SUM() producing wrong value.

Hey folks, I am getting some basic invoice information in a SQL query and figuring the Order Total and Payment Totals in the same query. Here is what I have thus far: SELECT orders.billerID, orders.invoiceDate, orders.txnID, orders.bName, orders.bStreet1, orders.bStreet2, orders.bCity, orders.bSta...

LINQ JOIN + GROUP BY + SUM

Hey there, I have two LINQ statements that I would like to make into one, but for the life of me I can't get it to work. I can't get the grouping to work in the first statement. It complains that the TotalBuy and TotalSell properties aren't there, although doesn't complain about AmountTC and AmountAUD. This should be simple. Any thou...

Is this sql syntax correct?

Can i apply SUM() within an ISNULL().... Consider my following sql server select statement SELECT e.Emp_Id,e.Identity_No,e.Emp_Name,case WHEN e.SalaryBasis=1 THEN 'Weekly' ELSE 'Monthly' end as SalaryBasis,e.FixedSalary, ISNULL(Adv.Daily_Wage,0) as Advance from Employee as e inner join Designation as d on e.Desig_Id=d.Desig_Id...

How can I select non-unique fields and their sum in db2?

I need to select unique codes and their sum(value) values. This does not work: select distinct t1.code, ( select sum(t2.value) from table2 t2 where t2.code = t1.code ) from table1 t1 example table: Code Value ABC 1 ABC 2 BCD 12345 expected: Code Value ABC 3 BCD 12345 actual: Code Value ABC (null) BCD (null) Thanks...

Matlab Bwareaopen equivalent function in OpenCV

hi! Im trying to find similar or equivalent funtion of Matlabs "Bwareaopen" function in OpenCV? In MatLab Bwareaopen(image,P) removes from a binary image all connected components (objects) that have fewer than P pixels. In my 1 channel image i want to simply remove small regions that are not part of bigger ones? Is there any trivial w...

result of the sum

Why 9.1 + 3.3 is not 12.4 ? <script> alert( 9.1 + 3.3 ) </script> result: 12.399999999 ...and how should I sum it? ...

Linq to Sql Sum with no records

I am creating a method that collects accumulated totals throughout the month. The problem is that there may not be charges for some of the items in a given month so no rows would be returned. I can see how this would error with no data: double fuelCost = (double)(from a in db.EquipmentFuelLogs where a.wdEqui...

LINQ - How can I use DataSet.DataRelation to join these tables and sum one field?

My LINQ query is not producing the expected output below. Basically, it's the sum of table3.cost corresponding to table2.code and table2.class categorized by table1.alias and ordered by table1.priority. I added two DataRelation's to the DataSet: ds.Relations.Add("Table1Table2", ds.Tables[1].Columns("ID"), ds.Tables[2].Columns("ParentI...

Jquery: Adding multiple values to textboxes (round two)

I don't think I explained myself as best I could last time, so I'm going to give it another shot. From the following code: <div id="addons" class="grid_12 omega"> <div class="addon"> <span><input type="checkbox" name="addon_1" value="addon_1"></span> <span class="title">Title 1 here</span> <span class="cost"...

Single MySQL query with count and sum

Hi there I have an SQL table that looks like this: CREATE TABLE IF NOT EXISTS `designerswave_article_visited` ( `article_visited_article_id` smallint(5) NOT NULL, `article_visited_user_id` smallint(5) NOT NULL, `article_user_rating` tinyint(1) DEFAULT NULL, UNIQUE KEY `article_id` (`article_visited_article_id`,`article_visited_...

MySQL: Counting most occurrences of a field's value

Given the following query, how do I return the p_name with the most transactions? And similarly, how do I return the t_amount with the most transactions. I'd like to do it all in this one query of course. SELECT t.*, p.* FROM transactions t LEFT JOIN partners p ON p.id=t.partner_id which can return something like: t_amount t_pla...