I have a PROJECTS table with PROJECT_ID, CUSTOMER_ID, COMPANY_ID and COST columns. One customer could have one or several projects in different companies. What I want is to choose a customer, who generates the smallest income for each company. I have a PROJECTS table with PROJECT_ID, CUSTOM