I have problem getting row from a max column, here the illustration : http://sqlfiddle.com/#!3/15207/9
basically I want to get the student's highest grade along with the grade-id (gid). but the query is not right because of using max grade id which will return 2.
First course taken, the student got D (1 point). Second time course taken, the student got E (0 point).
The gradeid for that 1 point is 1.
I expect the query result is: 1 (userid), 1 (subjectid), 1 (gradeid), 1 (score)
Thanks
UPDATE 01:
The more improved example: http://sqlfiddle.com/#!3/97997/2