Query won't do it by itself.
Create a new table. One field for the 'unique' values. A4, looks like.
qbe=query
:alias:table.db | quad |
| check calc count all as nquad |
endquery
qbe.executeqbe(":alias:quadflds.db")
Index the 'newtable.db' on 'quad' (first field). This is so you can use qlocate instead of locate[next].
Take the highest count, multiply * 5 (number of units + 1 for comma). This will be the size of the new field in the new table.
Use 2 tcursors, one opened on 'quadflds.db', one on new table. Note that you MUST at least attempt the unlockrecord. Otherwise, you may well end up with really messed up records in the new table you just created.
Code:
tcO.open(":alias:original.db")
tcT.open(":alias:newtable.db")
tcT.edit()
scan tcO :
if tcT.qlocate(tcO."quad") then
tcT."newfield"=tcT."newfield"+","+tcO."abbr"
else
tcT.insertrecord()
tcT."newfield"=tcO."abbr"
endif
try
tcT.unlockrecord()
onFail
; errorhandling
endTry
endscan
tcT.endedit()
tcT.close()
tcO.close()
Haven't tested, so may contain errors. Hopefully you get the idea, at least.
Tony McGuire
Stop Rob Bennett -
"It's not about having enough time; we have the rest of our lives. It's about priorities.