Skip to Main Content

Japanese

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Max of sum query

2676701May 22 2014

Hi there,

I'm trying to write a query that will list student(s) enrolled with the maximum total credit points.


Here is my query:


select s.S_ID, s.S_LAST, s.S_FIRST, s."Total Credits"

        from (select q2.S_ID, q2.S_LAST, q2.S_FIRST, sum(q1.CREDITS) "Total Credits"  from (select COURSE_NO, CREDITS from COURSE) q1 join

(select s.S_ID, s.S_LAST, s.S_FIRST, cs.COURSE_NO

from STUDENT s join ENROLLMENT e on s.S_ID = e.S_ID join COURSE_SECTION cs on e.C_SEC_ID = cs.C_SEC_ID) q2 on q1.COURSE_NO = q2.COURSE_NO

group by q2.S_ID, q2.S_LAST, q2.S_FIRST) q3

      group by s.S_ID, s.S_LAST, s.S_FIRST, s."Total Credits"

where "Total Credits" = max("Total Credits");

Doesn't seem to be working, this is the error:

ORA-00933: SQL command not properly ended

00933. 00000 -  "SQL command not properly ended"

*Cause:   

*Action:

Error at Line: 23 Column: 1

Would appreciate any help possible

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 19 2014
Added on May 22 2014
0 comments
969 views