Is this for a report sorted by company?
Then create a calc field
companyID ≠ GetNthRecord ( companyID ; Get ( RecordNumber ) - 1 )
and use a summary field SumOf, or a calc field
Case ( companyID ≠ GetNthRecord ( companyID ; Get ( RecordNumber ) - 1 ) ; 1 )
and a summary field TotalOf.
If you have FM13, you could create a summary field type ListOf for the customerID, and an (unstored) calculation field as
foundCustomerIDs = Substitute ( sListOfCustomerIDs ; ¶ ; "," ) ;
ExecuteSQL ( "
SELECT COUNT ( DISTINCT ( companyID ) )
WHERE customerID IN (" & foundCustomerIDs & ")
" ; "" ; ""
which works independently of any sort.