|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
arithmetic related!
I have a software which monitors the number of bytes downloaded/uploaded. The value is updated every 60 seconds so that it can be graphed. A typical table would be:
day month year time totalbytes bytes 24 11 2003 10.00 20 20 24 11 2003 10.01 20 0 24 11 2003 10.02 30 10 . . . 31 11 2003 01.00 340 15 . . 01 12 2003 03.45 500 25 . . ,where 'totalbytes' depicts the total number of bytes since the very first time the software was used, and 'bytes' is the number of bytes downloaded for that monitoring period (of 60 seconds). My aim is that everytime i log in, i know the total value of bytes i've downloaded during that month - I'm trying to do it in two ways: (1) I subtract the 'totalbytes' value at the 1st day of the month from the current 'totalbytes' value. This is ok but has a big downside that it excludes the downloaded value of the first day (arithmetic-wise) or (2) I select all the 'bytes' values and add them up for that month. This works fine. But this incurs more load since I have to add thousands of values (one value for every minute, thus, for one month of 31 days, I have to add 44,640 values, which I'm trying to avoid!!) My question is whether there is some SQL syntax which i'm missing, which could be used to tackle my somehow-looking-simple-problem in an efficient manner - i.e. knowing the totalbytes (which is an always cumulative value) since the first time i used the program, how can i get the number of bytes downloaded from the 1st day of that month till the date of making the query? thanks in advance - ganninu |
|
#2
|
|||
|
|||
|
what if you split the load?
- create a temp table, everytime data updates, it will add and store total to the temp table? Just do a simple select on the temp table, it will return "total" for you. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > arithmetic related! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|