sum of rows of mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

sum of rows of mysql

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're not making much sense..
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

ok i am sorry i will explain again!

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply