Page 1 of 1

sum of rows of mysql

Posted: Tue Mar 22, 2005 5:46 am
by pelegk2
i want to sum weight in rows.
date |weight|
-----------------------
1109746885,0 |
1110103200,11408 |
1110124465,13633 |
1110288332,0 |
-----------------------
i want to sum each weight by a certain date!
i want to sum each date like this :
1.1.2005 08:00:00 to 2.1.2005 07:59:59
2.1.2005 08:00:00 to 3.1.2005 07:59:59
and so on....
for example
1110103200=6.3.2005 12:00
1110124465=6.3.2005 17:45:25

and both of this dates from the table i want to some as 1 date!
can i do this in 1 query ormust i run in loops over the dates?
thnaks i nadvance
peleg

Posted: Tue Mar 22, 2005 8:57 am
by feyd
you're not making much sense..

Posted: Tue Mar 22, 2005 1:49 pm
by Chris Corbyn
feyd wrote:you're not making much sense..
LOL... I was looking at this for ages earlier but I thought it was just me being dumb :P

Do you mean average? - so the average weights between date1 and date2 kind of thing?

ok i am sorry i will explain again!

Posted: Wed Mar 23, 2005 1:59 am
by pelegk2
i have a col of date's
i want to sum all the weight but under this defenistion :
a "day of work" starts at 8:00: and end's at 7:59:59 in the day after it!
beacuse of that i gave example of 2 date's that are in the range of the same day but with a diffrent time!

so is i possible to get the sum of weight that are in the range of each "working day" withougt looping and asking for example :
1.1.2005 08:00:00 to 2.1.2005 07:59:59
2.1.2005 08:00:00 to 3.1.2005 07:59:59
and so on.....

hope i am clear now
thnaks i nadvance
peleg

Posted: Wed Mar 23, 2005 7:59 am
by feyd
okay.. so take the integer time you have, subtract 8 hours from it, convert it to a day value, and group the selection by that.