I have not tried this myself, but I was wondering…
If the DIDs go to different contexts, could you use a filter in the config file like ‘filter dcontext => departmenta’ where ‘departmenta’ is the name of the context you want in a specific table. You would have a section defined for each context with different values for filters.
If that does not work, perhaps you could userfield or even define you own column as a filter.
HOWEVER, I believe David may have been hinting at using a single table to store the data and use different views for retrieval. It would make the dial plan and configuration simpler and rely on a database feature to provide access to a subset of the data. For instance…
create view departmenta as select * from cdr where dst in ( ‘did1’,‘did2’,‘did3’,‘did4’);
Then ‘select * from departmenta’ is limited to just those 4 dids.
This approach has the benefit that Asterisk is already handling the writing of CDRs and the selection of a subset is handled by the database. If a new DID is created, the data will still be written by asterisk, you simply recreate the view or create a new on if the new DID is for a new Department/Group/Customer. Doing this via config files, in my opinion, would be… inconvenient.
I hope this helps.