Hello, I currently have a model called Job which has an attribute called CPU. This corresponds to the CPU time that a job was running. I would like to add all the time attributes of all the jobs for a specific date. This column is in the time format 00:00:00. Therefore I thought this would work:
def self.cpu_time
sum(:cpu)
end
Which...
Hello guys,
we've codeded this PHP-Script:
function price($id)
{
$ergebnis = mysql_query("SELECT * FROM preiszuordnungen where id=$id");
while($row = mysql_fetch_object($ergebnis))
{
//Wenn grundpreis dann färben
if($row->typ=="grundpreis")
{
...
heres a table, the time when the query runs i.e now is 2010-07-30 22:41:14
number | person | timestamp
45 mike 2008-02-15 15:31:14
56 mike 2008-02-15 15:30:56
67 mike 2008-02-17 13:31:14
34 mike 2010-07-30 22:31:14
56 bob 2009-07-30 22:37:14
67 bob 2009-07-30 22:37:14
22 ...
I've got a report that includes some limited duplicate information, there are multiple dates possible, but I want the dollar values to display on only the first item.
IE:
Item 1 - Aug 3, 2010 - Cost $1000
Item 1 - Aug 4, 2010 - (Cost suppressed)
Item 2 - Aug 3, 2010 - $100
Item 3 - Aug 4, 2010 - $200
When this is summed, it ...
In my schema, I have a table Projects, and a table Tasks. Each project is comprised of tasks. Each task has Hours and PercentComplete.
Example table:
ProjectID TaskID Hours PercentComplete
1 1 100 50
1 2 120 80
I am trying to get the weighted percentage complete for the project...
Hi there,
I want to select some entries based on a max+sum condition.
mytable
----------
id | col1 | col2
I want to select all entries that have the sum of col1 & col2 greater than or equal to the max of sum minus X. (don't ask me why :) )
So far I managed to get the sum OK (hereafter aliased as "total") with:
SELECT id,SUM(col1 +...
I have a collection of boxes with the properties weight, volume and owner.
I want to use LINQ to get a summarized list (by owner) of the box information
e.g.
**Owner, Boxes, Total Weight, Total Volume**
Jim, 5, 1430.00, 3.65
George, 2, 37.50, 1.22
Can someone show me how to do this with Lambda expression...
I have a database with the following schema:
ID PositionId LeagueId
1 4 5
3 4 5
3 8 5
4 1 6
I have this sql query in Access:
SELECT lp.PositionId
FROM Leagues l
INNER JOIN Lineups lp ON (l.LeagueID = lp.LeagueId)
GROUP BY PositionId
HAVING sum(iif(lp...
In Python,
I have list of dicts:
dict1 = [{'a':2, 'b':3},{'a':3, 'b':4}]
I want one final dict that will contain the sum of all dicts.
I.e the result will be: {'a':5, 'b':7}
N.B: every dict in the list will contain same number of key, value pairs.
...
I have a table where I have 6 columns. 5 of these columns I have to make sure that I don't have any duplicates. So I used the statement:
SELECT SUB_ACCT_NO_PAJ, CustomerType, POST_DTE_PAJ, IA_DateYear, ADJ_RSN_PAJ, count(*) AS [aCount]
INTO TempTable1
FROM All_Adjustments
GROUP BY SUB_ACCT_NO_PAJ, CustomerType, POST_DTE_PAJ, IA_DateYe...
Hi everyone,
I have two tables as follows
PRODUCT table
Id | Name | Price
And an ORDERITEM table
Id | OrderId | ProductId | Quantity
What I'm trying to do is, calculate the subtotal price for each product (Quantity*Price) then SUM the TOTAL value for the entire order..
I'm trying something like this
SELECT Id, SUM(Quantity * (s...
Hello,
I want a one-liner solution In Python of the following code but how?
total = 0
for ob in self.oblist:
total+=sum(v.amount for v in ob.anoutherob)
It returns total value. I want it one liner , plz any one help me
...
I have information on school athletics, with tables for school, season, cashflow, and cashflow_group. I'm trying to query for all schools with cashflow in one or more given cashflow_groups within a user-specified range. I need to query multiple different categories in the same query. I'm having trouble.
My query is below. The reason I d...
Python has a built in function sum, which is effectively equivalent to:
def sum(iterable, start):
return start + reduce(operator.add, iterable)
for all types of parameters except strings. It works for numbers and lists, for example.
Why were strings specially left out?
I seem to remember discussions in the Python list for the re...
I am searching the fastest way to count some tags in a huge xml-file (120MB)
long Quantity;
XPathDocument xDocData = new XPathDocument(str_File_path);
XPathNavigator xNavData = xDocData.CreateNavigator();
//Option 1
XPathExpression xExp = xNavData.Compile("sum(Tag/Value)");
Quantity = Convert.ToInt64(xNavData.Evaluate(xExp));
//Option...
Hi guys!
My question is related to this other discussion.
I'm trying to implement that algorithm using the dynamic program into a recursive call.
Problem statement:
Job j starts at sj, finishes at fj,and has weight or value vj.
Two jobs compatible if they don't overlap.
Goal: find maximum weight subset of mutually compatible jobs.
...
Via VB.Net, is there any way to access the AutoSum feature that Excel has? I have a spreadsheet that I create and populate via a datatable using my application. I know how to sum based upon a predefined range (e.g., .cells(cnt + 1, 21).Formula = "=Sum(U3:U" & cnt & ")") but is there any way that I can just call a cell in my worksheet an...
Hi,
I have a nxm matrix and I need to find the maximum of sum of its values in distinct rows and columns.
For example considering the following Matrix:
m1 m2 m3
n1 1 2 3
n2 4 5 6
n3 7 8 9
n4 10 11 12
The max will be 12+8+4 = 24
Note that finding the max and eliminating all values belonging to that column or ...
Assume you have an array of values that will need to be summed together
d = [1,1,1,1,1]
and a second array specifying which elements need to be summed together
i = [0,0,1,2,2]
The result will be stored in a new array of size max(i)+1. So for example i=[0,0,0,0,0] would be equivalent to summing all the elements of d and storing the ...
Hello,
I have a MySQL table with about 1000 rows, filled with different types of fruit trees and their locations on a farm. The data looks like this:
Fruit Trees Location on Farm
7 |
6 | G G
5 | G
Y 4 | G G
3 | A X G G
2 | A A A
1 |_ _ _ _ _ _ _
1 2 3 4 5 6 7
X
Fruit Trees MySQL Tab...