I think the following should work, try taking a look on the net for help on MySQL queries that use aggragate functions, there is probably a lot of info on there.

select exim.hour,sum(exim.count) from exim,servers where exim.machine=servers.id and servers.type='MX' and exim.date='2006-02-22' group by exim.hour

Regards
Ade

Ronan wrote:

select servers.type,exim.hour,exim.count from exim,servers where exim.machine=servers.id and servers.type='MX' and exim.date='2006-02-22'"

this gives me

+------+------+-------+
| type | hour | count |
+------+------+-------+
| MX   |    0 |  1117 |
| MX   |    0 |   366 |
| MX   |    0 |   147 |
| MX   |    1 |  1166 |
| MX   |    1 |   288 |
| MX   |    1 |   216 |
| MX   |    2 |  1176 |
| MX   |    2 |   256 |
| MX   |    2 |   169 |
| MX   |    3 |  1016 |
| MX   |    3 |   232 |
| MX   |    3 |   200 |
| MX   |    4 |  1186 |
| MX   |    4 |   311 |
| MX   |    4 |   216 |
| MX   |    5 |   905 |
| MX   |    5 |   297 |
| MX   |    5 |   129 |
| MX   |    6 |  1021 |
| MX   |    6 |   777 |
| MX   |    6 |   131 |
| MX   |    7 |   915 |
| MX   |    7 |   418 |
| MX   |    7 |   138 |
| MX   |    8 |  1506 |
| MX   |    8 |  1544 |
| MX   |    8 |   175 |
| MX   |    9 |  1949 |
| MX   |    9 |  2598 |
| MX   |    9 |   142 |
+------+------+-------+

I have 3 MXs...
I am running a perl script which queries the DB on request and draws GNUplot graphs...

Im looking at the websire but as im still a novice at this can anyone confirm , or gently shove me in the right direction on how I might take a sum of the 3 fields on the hourly field so I can hae a total count per hour?

I could do it in perl easily but I want to know if its possible in MySQL...

thanks

Ronan


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to