2014-05-19 2 views
0
select s.S_FIRST||' '||s.S_LAST, sum(c.CREDITS) from enrollment e,student s,course c 
where s.s_id=e.S_ID 
and c.COURSE_NO=e.C_SEC_ID 
group by s.S_ID 
having sum(c.credits)>12 order by s.s_id; 

Error report: 
SQL Error: ORA-00979: not a GROUP BY expression 
00979. 00000 - "not a GROUP BY expression" 

오류가 계속 발생합니다. 제안 사항이 있습니까? 협조ORA-00937을 극복하는 방법에 대한 제안이 있으십니까?

답변

0

에 대한

덕분에 실제로 SQL에서 몇 가지 문제가 있었다. 사용해보기 ...

select s.s_id, s.S_FIRST||' '||s.S_LAST name, sum(c.CREDITS) sum_credits 
from enrollment e,student s,course c 
where s.s_id=e.S_ID 
and c.COURSE_NO=e.C_SEC_ID 
group by 1, 2 
having sum(c.credits) > 12 
order by s.s_id; 

모든 비 집합 필드로 그룹화해야합니다. 또한 나는 당신이 당신의 질문에없는 분야에서 주문할 수 있다고 생각하지 않는다. (따라서 또한 선택 목록과 그룹으로 있어야한다.) 문서의 오류는 ORA-00937입니다.

유효하지 않은 숫자 의견을 기반으로 course_no에 가입이 잘못되었거나 크레딧이 숫자가 아닐 수도 있습니다.

0

그룹화 할 선택 목록에 모든 열을 포함 시키십시오. , 문서

Cause: The GROUP BY clause does not contain all the expressions in the SELECT clause. SELECT expressions that are not included in a group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, must be listed in the GROUP BY clause.

Action: Include in the GROUP BY clause all SELECT expressions that are not group function arguments

해결에서 여기 http://www.dba-oracle.com/t_ora_00979_not_a_group_by_expression.htm

참조하여 group by 절에 선택 목록에있는 모든 열을 포함한다. 오라클 사양 오류 ORA-01722

select s.S_FIRST||' '||s.S_LAST as fullname, s.s_id, 
sum(c.CREDITS) as total_credit from enrollment e, 
student s,course c 
where s.s_id=e.S_ID 
and c.COURSE_NO=e.C_SEC_ID 
group by s.S_FIRST||' '||s.S_LAST 
having total_credit > 12 
order by s.s_id; 

같은 쿼리를 변경할 수는 The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal.

의 모든 필드 INT 유형이나 같은 유형 확인을 의미합니다. IS c.CREDITS INT 유형?

은 같은 유형의 s.s_ide.S_ID입니까?

은 동일한 유형의 c.COURSE_NOe.C_SEC_ID입니까?

+0

안녕하세요,이 오류 보고서와 함께 돌아 왔습니다. SQL 오류 : ORA-01722 : 잘못된 번호 01722. 00000 - "잘못된 번호" – user3651097

+0

@user3651097, 편집 된 답변 확인. 지금 해봐. – Rahul

+0

@user3651097 도움이된다면 답을 수락하는 것을 잊지 마십시오. – Rahul

관련 문제