Grouping records
| From: | Matthew Halpin | Date: | Tue, 04 Nov 2008 01:15:38 +0000 |
| Subject: | Grouping records | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-282827@lists.php.net to get a copy of this message | ||
Hi,
I have transactional records with the following structure
Rowid Time Person Timediff Groupid
1 20:22:49 Bob
2 20:22:49 Bob 0
3 20:22:50 Bob 1
4 20:22:55 Bob 5
6 20:24:55 Bob 120
7 20:24:56 Bob 1
8 20:30:56 Kevin 360
9 20:30:57 Kevin 1
10 20:33:57 Kevin 180
(hope the formatting turns out)
What I would like to do is update the Groupid column with a number
starting at zero and increment where the timediff is greater than 60,
also starting from 0 again when the Person changes. Ending up with the
below.
Rowid Time Person Timediff Groupid
1 20:22:49 Bob
0
2 20:22:49 Bob 0
0
3 20:22:50 Bob 1
0
4 20:22:55 Bob 5
0
6 20:24:55 Bob 120
1
7 20:24:56 Bob 1
1
8 20:30:56 Kevin 360
0
9 20:30:57 Kevin 1
0
10 20:33:57 Kevin 180
1
Anyone got any ideas?
There will usually be more the 2 different people (number of people can
differ)
The number of groups can and will vary per person.