听起来你需要一个爆炸式的排序?多值 (MV) 字段虽然在 Basic 代码中非常方便,但在查询语言中处理起来可能有点麻烦。对它们有明确的支持,但它不像非 MV 数据那么简单。关键是进行“爆炸式”排序,这将使 MV 字段变平——我认为它为每个 MV 字段创建“虚拟”行。如果有多个 MV 字段并且它们彼此正确关联,它们将在虚拟行中链接在一起。单值和非关联的 MV 字段将在每个虚拟行中重复。很难解释,但对于您的问题,这里有一个示例查询:
查询和结果:
>sort IAN.TEMP BY.EXP ATB BREAK.ON ATB TOTAL COUNTER ID.SUP DET.SUP
ATB.. COUNT
CD2 3
CD3 3
CD4 2
CSR 3
IAN 2
=====
TOTAL 13
13 records listed
设置字典:
>AE DICT IAN.TEMP ATB COUNTER
< 1 > Top of "ATB" in "DICT IAN.TEMP", 7 lines, 11 characters.
*--: P
001: D
002: 1
003:
004:
005: 5L
006: M <--- This is very important! Must be M (or MV) for BY.EXP to work
007: <--- If there are associated MV fields, this needs to be populated
Bottom.
*--: EX
Quit "ATB" in file "DICT IAN.TEMP" unchanged.
< 2 > Top of "COUNTER" in "DICT IAN.TEMP", 6 lines, 10 characters.
*--: P
001: I
002: 1 <-- This just returns "1" for every row in the output, to help with totals
003:
004:
005: 5R
006: S
Bottom.
*--: EX
Quit "COUNTER" in file "DICT IAN.TEMP" unchanged.
设置样本数据:
>AE IAN.TEMP *
4 record(s) selected.
< 1 > Top of "3" in "IAN.TEMP", 1 line, 7 characters.
*--: P
001: CD2▒IAN
Bottom.
*--: EX
Quit "3" in file "IAN.TEMP" unchanged.
< 2 > Top of "1" in "IAN.TEMP", 1 line, 15 characters.
*--: P
001: CSR▒CD2▒CD3▒IAN
Bottom.
*--: EX
Quit "1" in file "IAN.TEMP" unchanged.
< 3 > Top of "4" in "IAN.TEMP", 1 line, 15 characters.
*--: P
001: CSR▒CD2▒CD3▒CD4
Bottom.
*--: EX
Quit "4" in file "IAN.TEMP" unchanged.
< 4 > Top of "2" in "IAN.TEMP", 1 line, 11 characters.
*--: P
001: CD4▒CD3▒CSR
Bottom.
*--: EX
Quit "2" in file "IAN.TEMP" unchanged.