In order to fetch the data from different companies use cross company keyword.
below code is used to fetch the data from custtable from all the three companies mentioned in the container.
static void crosscompanies(Args _args)
container conCompanies = [‘dat’, ‘text’,’AXT’ ];
while select crosscompany : conCompanies * from custTable
//order by custgroup