I didn't test it but you may try something like: SELECT ddi, sum(tot_dur) FROM table GROUP BY ddi ORDER BY ddi
On Mon, 2003-01-20 at 12:59, Steve Mansfield wrote: > Using mysql 3.23.51 > I have a mysql table that holds records for telephone traffic. > The table fields are as follows: > > id start stop > cli ddi tot_dur > day_dur eve_dur wkd_dur > 1 08/12/2002--23:50:00 09/12/2002--02:23:55 1507608105 > 08451340206 9235 0 8635 600 > 2 09/12/2002--00:14:15 09/12/2002--00:15:08 1634324824 > 08451340120 53.1 0 53.1 0 > 3 09/12/2002--00:20:17 09/12/2002--00:20:59 1634324824 > 08451340120 41.9 0 41.9 0 > 4 09/12/2002--00:28:00 09/12/2002--00:28:46 1634324824 > 08451340120 46 0 46 0 > 5 09/12/2002--00:30:25 09/12/2002--00:31:04 1634324824 > 08451340120 38.9 0 38.9 0 > 6 09/12/2002--03:22:30 09/12/2002--05:08:43 1507608105 > 08451340206 6372.9 0 6372.9 0 > 7 09/12/2002--05:25:25 09/12/2002--05:35:56 1622859384 > 08451340214 631.6 0 631.6 0 > > > What i'm trying to do is run a query that will give me the sum tot_dur > for each distinct ddi > ie: distinct ddi will give me the list of all the ddi numbers that were > called but i need the sum of tot_dur for each distinct ddi. > so it should produce an output like: > > ddi tot_dur > 08451340120 179.9 > 08451340206 15607.9 > 08451340214 631.6 > > Anyone have any ideas as i just cannot get the query correct. > > > Steve Mansfield > [EMAIL PROTECTED] > > http://www.getreal.co.uk > Real Data Services Ltd 117-119 Marlborough Road Romford Essex RM7 8AP > [Office] 0870 757 7900 [Fax] 0870 757 8900 > http://www.be-an-isp.com http://www.isdn4free.co.uk >http://signup.getreal.co.uk > For our email disclaimer please see the url below. > http://www.getreal.co.uk/disclaimer.htm -- Diana Soares --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php