表结构
id | spu_code | wk |
---|---|---|
1 | 1 | 1 |
2 | 1 | 2 |
3 | 1 | 3 |
4 | 1 | 1 |
5 | 1 | 2 |
6 | 1 | 7 |
7 | 1 | 11 |
8 | 2 | 7 |
9 | 1 | 11 |
- 唯一标识:spu_code
- 时间字段:wk
计算sql
1 | SELECT s.spu_code AS spu_code, s.wk AS wk, t.wk AS k_wk |
计算结果
spu_code | wk | k_wk |
---|---|---|
1 | 1 | 2 |
1 | 1 | 3 |
1 | 1 | 7 |
1 | 1 | 11 |
1 | 2 | 3 |
1 | 2 | 7 |
1 | 3 | 7 |
1 | 11 | 2 |
1 | 11 | 3 |
1 | 11 | 7 |