Jump to content

Archived

This topic is now archived and is closed to further replies.

renalfuck

[Resolvido] Erro com Group by

Recommended Posts

Exibir o nome e dos funcionários que recebem salário acima da média.

 

SELECT ENAME, AVG(SAL)
FROM EMP
WHERE ENAME = '%'
GROUP BY ENAME
HAVING SAL > AVG(SAL)
ORDER BY ENAME;
HAVING SAL > AVG(SAL)
*

ERRO na linha 5:

ORA-00979: não é uma expressão GROUP BY

 

O que posso fazer para corrigir este erro ?? Por favor alguem me ajude

Share this post


Link to post
Share on other sites

Média

 

SELECT AVG(SAL)
FROM EMP
WHERE ENAME = '%'

Acima dela

 

SELECT *
FROM EMP
WHERE ENAME = '%'
AND SAL > (SELECT AVG(SAL)
           FROM EMP
           WHERE ENAME = '%')

Share this post


Link to post
Share on other sites

Média

 

SELECT AVG(SAL)
FROM EMP
WHERE ENAME = '%'

Acima dela

 

SELECT *
FROM EMP
WHERE ENAME = '%'
AND SAL > (SELECT AVG(SAL)
           FROM EMP
           WHERE ENAME = '%')

 

 

Muito Obrigado foi extremamente util !

Share this post


Link to post
Share on other sites

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.