Steve Endow looks at options for multi-company GP queries and comes away with a Very impressive SQL script for running multi-company Dynamics GP queries
Dynamics GP Land: Very impressive SQL script for running multi-company Dynamics GP queries
Archived post from 2017. Dynamics GP and the links it points to have changed since; check current documentation before relying on version-specific steps.