I have three table
EMPLOYEE table with ID and NAME
COMPANY table with ID and NAME
and
SALARY table with EMPLOYEE_ID, COMPANY_ID and SALARY
I wanted to print the name of every company where the average salary is greater than or equal to 40000
My query is
Select distinct COMPANY.NAME from COMPANY,SALARY,EMPLOYEE WHERE SALARY.COMPANY_ID=COMPANY.ID and (select avg(SALARY) from SALARY,EMPLOYEE WHERE SALARY.EMPLOYEE_ID=EMPLOYEE.ID) >=40000;