List:General Discussion« Previous MessageNext Message »
From:Brian Power Date:February 10 2004 3:21pm
Subject:RE: GROUP BY question
View as plain text  
I'm not sure if it is possible to do with a group by

Say you had
1   2004-02-02 12:00:00
2   2004-02-02 12:00:05
3   2004-02-02 12:00:09
4   2004-02-02 12:00:12

this would require 1,2 and 3 in one group and
2,3,4 in another. My understanding is that you cant have the same rec in two 
groups

I think you would need to do this with code.


If anyone can suggest a way with SQL I'd be very interested

Brian Power

>From: Bengt Lindholm <bengt.lindholm@stripped>
>To: mysql@stripped
>Subject: GROUP BY question
>Date: Tue, 10 Feb 2004 15:24:06 +0100
>
>I have a table where I need to group the content on a timestamp. Any record 
>that is less than say 5 minutes from any other record needs to be grouped 
>with that other record.
>
>ID   timestamp
>  1   2004-02-02 12:00:00
>  2   2004-02-02 12:00:05
>  3   2004-02-02 12:05:20
>  4   2004-02-02 12:15:00
>  5   2004-02-02 12:17:15
>  6   2004-02-02 12:21:20
>
>With this recordset I would get:
>1 & 2 should be grouped since there's less than 5 minutes between the 
>records
>3 will be in a group of its own
>4, 5 & 6 is a third group since any record in the group has less than 5 
>minutes to another record in the group
>
>Is this possible to do in MySQL, and how is it accomplished?
>
>
>
>Regards,
>
>
>Bengt Lindholm
>
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:    
>http://lists.mysql.com/mysql?unsub=1
>

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

Thread
GROUP BY questionBengt Lindholm10 Feb
  • Re: GROUP BY questionRoger Baklund11 Feb
RE: GROUP BY questionBrian Power10 Feb
  • Re: GROUP BY questionBengt Lindholm10 Feb
    • Re: GROUP BY questionJochem van Dieten10 Feb