Hi Aveek,

I think Ghulam just want to count calls for each intervals
so the query should looks like this:

select count(*) as total_calls, queue_seconds
from calls group by queue_seconds order by total_calls;


----- Original Message -----
From: "Aveek Misra" <ave...@yahoo-inc.com>
To: "Ghulam Mustafa" <mustafa...@gmail.com>, mysql@lists.mysql.com
Sent: Tuesday, July 27, 2010 5:54:13 PM
Subject: RE: query results group/summed by interval

try this ...

 select 5 * floor(seconds/5) as start, 5 * floor(seconds/5) + 5 as end, 
sum(calls) from calls group by 5 * floor(seconds/5);

This should give you an output of the type

+-------+------+------------+
| start | end  | sum(calls) |
+-------+------+------------+
|     0 |    5 |        387 |
|     5 |   10 |        225 |
|    10 |   15 |         74 |
+-------+------+------------+


Thanks
Aveek
________________________________________
From: Ghulam Mustafa [mustafa...@gmail.com]
Sent: Tuesday, July 27, 2010 3:53 PM
To: mysql@lists.mysql.com
Subject: query results group/summed by interval

Hi everyone,

i have two columns (seconds, number of calls), i need to produce a
report which will show total number of calls in intervals (let'say 10
seconds interval), i know i can do this programmability in my script but
i was wondering if it's possible to accomplish this behavior within
mysql. for example i have following data.

+----------+---------------+
|  calls   | queue_seconds |
+----------+---------------+
|      250 |          0.00 |
|       28 |          1.00 |
|       30 |          2.00 |
|       56 |          3.00 |
|       23 |          4.00 |
|       31 |          5.00 |
|       33 |          6.00 |
|       50 |          7.00 |
|       49 |          8.00 |
|       62 |          9.00 |
|       74 |         10.00 |
...
... and so on...
...
+----------+---------------+

now result should look like this with a 5 seconds interval.

+----------+---------------+
| count(*) | queue_seconds |
+----------+---------------+
|      250 |          0.00 |
|      168 |          5.00 |
|      268 |         10.00 |
...
... and so on...
...
+----------+---------------+

i would really appreciate your help.

Best Regards.

--
Ghulam Mustafa

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=ave...@yahoo-inc.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=cuong.m...@vienthongso.com


-- 
Best Regards,
Cuongmc.

-- 
Nguyen Manh Cuong
Phong Ky Thuat - Cong ty Vien Thong So - VTC
Dien thoai: 0912051542
Gmail     : philipscu...@gmail.com
YahooMail : philipscu...@yahoo.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to