我正在尝试通过某些数据更改来对表进行分区(不知道如何解释)
最好的例子
我有一个这样的表(例如简化):
| ID | TEST_DATA | LOGDATETIME |
------------------------------------------------
| 1 | a | June, 19 2013 00:13:23+0000 |
| 2 | a | June, 19 2013 00:13:24+0000 |
| 3 | a | June, 19 2013 00:13:25+0000 |
| 4 | b | June, 19 2013 00:13:26+0000 |
| 5 | b | June, 19 2013 00:13:27+0000 |
| 6 | b | June, 19 2013 00:13:28+0000 |
| 7 | a | June, 19 2013 00:13:29+0000 |
| 8 | a | June, 19 2013 00:13:30+0000 |
| 9 | a | June, 19 2013 00:13:31+0000 |
我想通过测试数据进行分区(组),如下所示:
| ID | TEST_DATA | LOGDATETIME | grouping
------------------------------------------------
| 1 | a | June, 19 2013 00:13:23+0000 | 1
| 2 | a | June, 19 2013 00:13:24+0000 | 1
| 3 | a | June, 19 2013 00:13:25+0000 | 1
| 4 | b | June, 19 2013 00:13:26+0000 | 2
| 5 | b | June, 19 2013 00:13:27+0000 | 2
| 6 | b | June, 19 2013 00:13:28+0000 | 2
| 7 | a | June, 19 2013 00:13:29+0000 | 3
| 8 | a | June, 19 2013 00:13:30+0000 | 3
| 9 | a | June, 19 2013 00:13:31+0000 | 3
我想保留日志时间的顺序,但每次 TEST_DATA 更改时都会创建一个新分组
SQLFiddle:http ://sqlfiddle.com/#!12/d9c17/1