Grouping records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux