我有一个表,其中每条记录是:ID、groupID 和一个注释字段。ID 不是唯一的,它可以与多个 groupID 关联。并且每个 ID-groupID 组合可以与多个注释相关联。我在这里尝试打印的主要数据是注释字段。
id | groupID | notes
------------------------------------------------------------------
JWOFJ903JCKDF8 | groupID-22 | new id, new id-groupID combo
JWOFJ903JCKDF8 | groupID-33 | repeat id (line 1), new id-groupID combo
JWOFJ903JCKDF8 | groupID-33 | repeat id (lines 1&2), repeat id-groupID (line 2)
...
DF8#CKJ90JJ3WO | groupID-22 | new id, new id-groupID combo
DF8#CKJ90JJ3WO | groupID-44 | repeat id (line 4), new id-groupID combo
...
打印数据时,如何选择笔记,以便将属于同一 ID-groupID 组合的所有笔记组合在一起?并且所有属于同一 id 的 groupID 都分组在一起?
所以我的报告看起来像这样:
JWOFJ903JCKDF8
-groupID-22
- [line 1 of the data] new id, new id-groupID combo
-groupID-33
- [line 2 of the data] repeat id (line 1), new id-groupID combo
- [line 3 of the data] repeat id (lines 1&2), repeat id-groupID (line 2)
DF8#CKJ90JJ3WO
-groupID-22
- [line 4 of the data] new id, new id-groupID combo
-groupID-44
- [line 5 of the data] repeat id (line 4), new id-groupID combo
我应该指出,这张表非常大——超过 200,000 条记录并且还在增长。