Trabalho sql
GROUP BY 1 HAVING SUM(CAS.SALARIO) > (SELECT AVG(CASS.SALARIO) FROM CARGOSSALARIOS CASS INNER JOIN CARGO CARR ON CARR.IDCARGO = CASS.IDCARGO INNER JOIN DEPARTAMENTO DEPP ON DEPP.IDDEPARTAMENTO = CARR.IDDEPARTAMENTO WHERE CASS.IDCARGO NOT IN(1,2,3,4,5) )
SELECT DEP.DESCRICAO AS DESCRICAO, PAR.DESCRICAO AS NOME, CAS.SALARIO AS SALARIO FROM DEPARTAMENTO DEP INNER JOIN CARGO CAR ON CAR.IDDEPARTAMENTO = DEP.IDDEPARTAMENTO INNER JOIN CARGOSSALARIOS CAS ON CAS.IDCARGO = CAR.IDCARGO INNER JOIN PARCEIRO PAR ON PAR.IDCARGO = CAR.IDCARGO WHERE CAS.IDCARGO NOT IN(1,2,3,4,5) AND CAS.SALARIO = (SELECT MAX(CASS.SALARIO) FROM CARGOSSALARIOS CASS WHERE CASS.IDCARGO NOT IN(1,2,3,4,5))
SELECT DEP.DESCRICAO AS DESCRICAO, PAR.DESCRICAO AS NOME, CAS.SALARIO AS SALARIO FROM DEPARTAMENTO DEP INNER JOIN CARGO CAR ON CAR.IDDEPARTAMENTO = DEP.IDDEPARTAMENTO INNER JOIN CARGOSSALARIOS CAS ON CAS.IDCARGO = CAR.IDCARGO INNER JOIN PARCEIRO PAR ON PAR.IDCARGO = CAR.IDCARGO WHERE CAS.IDCARGO NOT IN(1,2,3,4,5) AND CAS.SALARIO = (SELECT MIN(CASS.SALARIO) FROM CARGOSSALARIOS CASS WHERE CASS.IDCARGO NOT