sum

sum all input elements in jquery...

Trying to figure out how to write a jquery formula that will sum all input fields that begin with "pull" on keyup... I'm trying the code below, but nothing happens... No errors, and no updates either.... (the html is at the very bottom) $(document).ready(function(){ /* sums pull total input fields */ $("input[name^='pull']").bi...

Calculate the sum of DIV content

Hi all, I have a form with several SELECT boxes and based on the user's selection a value appears. This is fully working. Now I want a script that calculates the SUM of these values either automatically or when pressing a button. The full code I have so far is this: The JavaScript: <script type="text/javascript"> window.onload=funct...

Get sum of two columns in one LINQ query

Hi, let's say that I have a table called Items (ID int, Done int, Total int) I can do it by two queries: int total = m.Items.Sum(p=>p.Total) int done = m.Items.Sum(p=>p.Done) But I'd like to do it in one query, something like this: var x = from p in m.Items select new { Sum(p.Total), Sum(p.Done)}; Surely there is a way to call agg...

finding the number of 1's in my table in order

I have a table of customers with a 1 recorded against their customerid on different dates. I would like to find the sum of the 1's recorded in descending order. I'm using MySQL and php Thanks ...

making a combined sum of two columns

I have a table (apples) containing: cid date_am date_pm ---------------------- 1 1 1 2 2 1 3 1 3 1 1 2 I asked a question earlier (badly) about how I would rank the customers in order of the number of ones(1) they had. The solution was (based on one column): SELECT cid, sum( date_pm ) A...

MYSQL sum() for distinct rows

I'm looking for help using sum() in my SQL query: SELECT links.id, count(DISTINCT stats.id) as clicks, count(DISTINCT conversions.id) as conversions, sum(conversions.value) as conversion_value FROM links LEFT OUTER JOIN stats ON links.id = stats.parent_id LEFT OUTER JOIN conversions ON links.id = conversions.l...

SELECT SUM returns a row when there are no records

Hi, I'm finding some problems with a query that returns the sum of a field from a table for all the records that meet certain conditions. I expected to receive a "No records found' when there were no records, but instead I'm receiving a null result. SQL> SELECT * FROM DUAL WHERE 1=2; no rows selected SQL> SELECT SUM(dummy) FROM DUAL W...

How to limit results by SUM

I have a table of events called event. For the purpose of this question it only has one field called date. The following query returns me a number of events that are happening on each date for the next 14 days: SELECT DATE_FORMAT( ev.date, '%Y-%m-%d' ) as short_date, count(*) as date_count FROM event ev WHERE ev.date >= NOW() GR...

jQuery: How do I sum a column of numbers with commas?

I used the following function I found online and it works perfectly. However, when my user later asked for commas to be included in the numbers, it broke. It only adds the numbers preceding the comma. Here is the function: function sumOfColumns(tableID, columnIndex, hasHeader) { var tot = 0; $("#" + tableID + " ...

SQL Update to the SUM of its joined values

Hi, I'm trying to update a field in the database to the sum of its joined values: UPDATE P SET extrasPrice = SUM(E.price) FROM dbo.BookingPitchExtras AS E INNER JOIN dbo.BookingPitches AS P ON E.pitchID = P.ID AND P.bookingID = 1 WHERE E.[required] = 1 When I run this I get the following error: "An aggregate may not appear in the...

How do I find the sum of all values from two different arrays in Perl?

How to find the sum of all values from two different arrays in Perl? @array1 = (1, 2, 3); @array2 = (10, 10, 10); @sumofarray1and2 = ? So I figured I can do two kinds of things here. I can do two foreach loops and add contents of @array1 and @array2 first then get the sum of both. ...

sql question regarding sum() and tax (MySQL 5.0.89)

Select id, sum(amount), vat From transactions WHERE id=1; Each record in this table has a vat percentage, I need to get the total amount in all records, however each amount has to be multiplied by its vat %. Is there away to do this without looping through all records? ...

MS-Access 2007 Time Online Report

I have the following data in my database: MemberID | DateTime ------------------------------------- 1 | 31/03/2010 3:45:49 PM 2 | 31/03/2010 3:55:29 PM 1 | 31/03/2010 4:45:49 PM Every time a user is authenticated or un-authenticated this log appears in the database. What I want to be able to do is total th...

How do you work with IList<> in F#?

I have a list of type IList<Effort>. The model Effort contains a float called Amount. I would like to return the sum of Amount for the whole list, in F#. How would this be achieved? ...

Oracle(10) SQL: calculating final sum depending on two field

First the disclaimer: I never learnt any programming in school, and just have to deal with various SQL problems (too). So now I've got two tables, TABLE1: ACCNO BAL1 BAL2 11111 20 10 And TABLE2 (which has the ACCNO key, of course) related rows to '11111': DATENUM AMT 1 -5 2 -10 3 8 4 -23 5 100 6 ...

SUM minutes SQL server

HI guys, My litle problem goes like this : I have this columns : PHONE_NR , TIME ( time field ), Meaning the calling telephone number and call duration. I need to group phone nr and sum the minutes. Filds looks like this : nr time 726028xxx 00:07:07 735560css 00:07:37 726028xxx 00:07:55 ...

How to SUM() from an offset through the end of the table?

If SELECT SUM(amount) FROM transactions ORDER BY order LIMIT 0, 50 sums the amount field for the first 50 records in a table, how do a sum all records after the first 50? In other words, I'd like to do something like SELECT SUM(amount) from transactions ORDER BY order LIMIT 50, *, but that doesn't work. ...

Fastest possible summing numbers up to N

Okay so i need really FAST algorithm or code in C if you have any it would be nice. The task is to sum all numbers from 1 to N for a given number N (it can be negative number too), so i did the usual way (you know just summing with loop from 1 to N) but it's not fast enough - i need something faster, i guess that i need the fastest possi...

How do I combine two rows of same part, but add quantities?

I have table "PICKITEM" PARTID QTY A 1 A 3 B 11 C 8 D 5 D 3 I need a select statement that will return one line for like PARTIDs and add the qty field to together, yet also return the rest of the lines in the table as is PARTID QTY A 4 B 11 C ...

SQL - Add up all row-values of one column in a singletable

Hello Everybody, I've got a question regarding a SQL-select-query: The table contains several columns, one of which is an Integer-column called "size" - the task I'm trying to perform is query the table for the sum of all rows (their values), or to be more exact get a artifical column in my ResultSet called "overallSize" which contains ...