Find CAM import with bills from multiple companies - Redcrest-Solutions/FlyingFleet-issues GitHub Wiki

SELECT ImportPaymentItems.ImportPaymentId, Bills.Id  FROM ImportPaymentItems LEFT JOIN Bills ON Bills.Id=ImportPaymentItems.BillId
LEFT JOIN ImportPayments ON ImportPayments.Id = ImportPaymentItems.ImportPaymentId WHERE BillId is not null AND Bills.VatAccountId <> ImportPayments.VatAccountId