sql - Oracle viewing highest record -
I have a module and a student's host, trying to display only one record of the student with the highest result for specific modules But I can not get it to work. Here is my SQL syntax:
SELECT S.ST_FNAME, S.ST_LNAME, M.MOD_NAME, R.RES_GRADE to Student S, Module M, Result RWERE S.ST_ID = R ST_ID and M .MOD_ID = R.MOD_ID and M.MOD_ID = 503;
To get a single value for a group of rows, use GROUP BY (in your case, max to get the maximum):
< Add class_select S.ST_FNAME, S.ST_LNAME, M.MOD_NAME, MAX (R.RES_GRADE) to max_grade R.MOD_ID = M.MOD_ID at S.ST_ID = R.ST_ID on module M. WHERE M.MOD_ID = 503 group s.st_fname, s.st_lname, m.mod_name;
I have also made changes in your old style of joining ANSI-style - using the ANSI style, today it is preferred by most people.
Comments
Post a Comment