Re: [PHP] SQL sums

2004-12-04 Thread Marek Kilimajer
Raditha Dissanayake wrote:
Marek Kilimajer wrote:
Jason Wong wrote:
On Saturday 04 December 2004 00:40, Marek Kilimajer wrote:
Raditha Dissanayake wrote:
Marek Kilimajer wrote:
This is an SQL question.

Marek, don't you know that this the mysql list? you are supposed to
answer questions like these. If you don't there will be self appointed
list moderators who will jump on you like what happened to me last 
week.
I was accused of being not helpfull.

Ok, I appologize :)))


I think Raditha had his tongue firmly in his cheek when he wrote that.
Does anyone know of a good remedy for cheek pain? (or is that an off 
topic question?)
I did not find any cheek-pain-remedy list, so I think it's fine to ask 
here. I'll ask the moderators to add it to the subjects as number ... 
integer overflow.

:-D
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] SQL sums

2004-12-03 Thread James Nunnerley
I'm trying to create a table, and ultimately a graph, out of some syslog
data.

 

I have a mysql table with the following info in it:

Time (unixtime stamp), bytes rcvd and bytes sent

 

I want to create a sql statement that group the data over a certain period
of time, and produces the following table:

 


Time

Sent

Rcvd


From x to y

Total bytes sent during period x to y

Total bytes rcvd during period x to y


From y to z

Total bytes sent during period y to z

Total bytes rcvd during period y to z


From z to a

Total bytes sent during period z to a

Total bytes rcvd during period z to a


From a to b

Total bytes sent during period a to b

Total bytes rcvd during period a to b

 

Now to create this I've tried a horrible method of using php to call sql
table, and then go through each one, and add it to each period of time as
appropriate. it's messy and slow!

 

What I want to do is have the mysql do this.is it possible?

 

Cheers

Nunners



RE: [PHP] SQL sums

2004-12-03 Thread Thomas S. Crum - AAA Web Solution, Inc.
If someone doesn't give you an answer here, try php cookbook by O'reilly.

It has this exact recipe in it.

Best,

Thomas S. Crum

-Original Message-
From: James Nunnerley [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 03, 2004 9:56 AM
To: [EMAIL PROTECTED]
Subject: [PHP] SQL sums

I'm trying to create a table, and ultimately a graph, out of some syslog
data.

 

I have a mysql table with the following info in it:

Time (unixtime stamp), bytes rcvd and bytes sent

 

I want to create a sql statement that group the data over a certain period
of time, and produces the following table:

 


Time

Sent

Rcvd


From x to y

Total bytes sent during period x to y

Total bytes rcvd during period x to y


From y to z

Total bytes sent during period y to z

Total bytes rcvd during period y to z


From z to a

Total bytes sent during period z to a

Total bytes rcvd during period z to a


From a to b

Total bytes sent during period a to b

Total bytes rcvd during period a to b

 

Now to create this I've tried a horrible method of using php to call sql
table, and then go through each one, and add it to each period of time as
appropriate. it's messy and slow!

 

What I want to do is have the mysql do this.is it possible?

 

Cheers

Nunners

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SQL sums

2004-12-03 Thread Marek Kilimajer
This is an SQL question.
James Nunnerley wrote:
I'm trying to create a table, and ultimately a graph, out of some syslog
data.
 

I have a mysql table with the following info in it:
Time (unixtime stamp), bytes rcvd and bytes sent
 

I want to create a sql statement that group the data over a certain period
of time, and produces the following table:
 

Time
Sent
Rcvd

From x to y
Total bytes sent during period x to y
Total bytes rcvd during period x to y

From y to z
Total bytes sent during period y to z
Total bytes rcvd during period y to z

From z to a
Total bytes sent during period z to a
Total bytes rcvd during period z to a

From a to b
Total bytes sent during period a to b
Total bytes rcvd during period a to b
 

Now to create this I've tried a horrible method of using php to call sql
table, and then go through each one, and add it to each period of time as
appropriate. it's messy and slow!
 

What I want to do is have the mysql do this.is it possible?
 

Cheers
Nunners

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SQL sums

2004-12-03 Thread John Nichel
Marek Kilimajer wrote:
This is an SQL question.
snip
Yes, but this is the 
php-general_mysql_javascript_wax-my-car_html_apache_kitchen-sink list.  ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SQL sums

2004-12-03 Thread Raditha Dissanayake
Marek Kilimajer wrote:
This is an SQL question.
Marek, don't you know that this the mysql list? you are supposed to 
answer questions like these. If you don't there will be self appointed 
list moderators who will jump on you like what happened to me last week. 
I was accused of being not helpfull.

James Nunnerley wrote:
I'm trying to create a table, and ultimately a graph, out of some syslog
data.
 

I have a mysql table with the following info in it:


--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SQL sums

2004-12-03 Thread Marek Kilimajer
Raditha Dissanayake wrote:
Marek Kilimajer wrote:
This is an SQL question.

Marek, don't you know that this the mysql list? you are supposed to 
answer questions like these. If you don't there will be self appointed 
list moderators who will jump on you like what happened to me last week. 
I was accused of being not helpfull.
Ok, I appologize :)))
This should get you started:
SELECT s1.add_time, sum(s2.sent) sent_total, sum(s2.received) 
received_total FROM sum_by_time s1, sum_by_time s2 WHERE (s1.add_time  
s2.add_time  and s1.add_time  s2.add_time + 10)  group by 
FLOOR(s1.add_time / 10)



James Nunnerley wrote:
I'm trying to create a table, and ultimately a graph, out of some syslog
data.
 

I have a mysql table with the following info in it:


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SQL sums

2004-12-03 Thread Greg Donald
On Fri, 3 Dec 2004 14:55:46 -, James Nunnerley
[EMAIL PROTECTED] wrote:
 I'm trying to create a table, and ultimately a graph, out of some syslog
 data.
 
 I have a mysql table with the following info in it:
 
 Time (unixtime stamp), bytes rcvd and bytes sent

Why reinvent the wheel?  Use MRTG.

http://people.ee.ethz.ch/~oetiker/webtools/mrtg/


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SQL sums

2004-12-03 Thread Richard Lynch
 Now to create this I've tried a horrible method of using php to call sql
 table, and then go through each one, and add it to each period of time as
 appropriate. it's messy and slow!

Yes!

To generalize:

ANY time you try to get PHP to access SQL data row by row, and do
something with it (other than spew it to the browser) you are DOING IT
WRONG.

(Does this sound familiar?)

So you've learned your lesson now, and won't do this ever again. :-)

 What I want to do is have the mysql do this.is it possible?

Sure!

But there's no PHP question left here, really.

You want to dig around in MySQL documentation for something called
sum... Pretty much what your subject line should have led you to.  In
fact, I daresay if you typed your subject line into Google SQL sums
you'd have found the answer... :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SQL sums

2004-12-03 Thread Jason Wong
On Saturday 04 December 2004 00:40, Marek Kilimajer wrote:
 Raditha Dissanayake wrote:
  Marek Kilimajer wrote:
  This is an SQL question.
 
  Marek, don't you know that this the mysql list? you are supposed to
  answer questions like these. If you don't there will be self appointed
  list moderators who will jump on you like what happened to me last week.
  I was accused of being not helpfull.

 Ok, I appologize :)))

I think Raditha had his tongue firmly in his cheek when he wrote that.

 This should get you started:

[snip]

Stop it! You're encouraging people to post OT stuff.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The greatest remedy for anger is delay.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SQL sums

2004-12-03 Thread Marek Kilimajer
Jason Wong wrote:
On Saturday 04 December 2004 00:40, Marek Kilimajer wrote:
Raditha Dissanayake wrote:
Marek Kilimajer wrote:
This is an SQL question.
Marek, don't you know that this the mysql list? you are supposed to
answer questions like these. If you don't there will be self appointed
list moderators who will jump on you like what happened to me last week.
I was accused of being not helpfull.
Ok, I appologize :)))

I think Raditha had his tongue firmly in his cheek when he wrote that.
So did I ;-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] SQL sums

2004-12-03 Thread Raditha Dissanayake
Marek Kilimajer wrote:
Jason Wong wrote:
On Saturday 04 December 2004 00:40, Marek Kilimajer wrote:
Raditha Dissanayake wrote:
Marek Kilimajer wrote:
This is an SQL question.

Marek, don't you know that this the mysql list? you are supposed to
answer questions like these. If you don't there will be self appointed
list moderators who will jump on you like what happened to me last 
week.
I was accused of being not helpfull.

Ok, I appologize :)))

I think Raditha had his tongue firmly in his cheek when he wrote that.
Does anyone know of a good remedy for cheek pain? (or is that an off 
topic question?)

So did I ;-)

--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php