Table A
- tableAID
- tableBID
- grade
Table B
- tableBID
- name
- description
Table A links to Table b from the tableBID found in both tables.
If I want to find the row in Table A, which has the highest grade, for each row in Table B, I would write my query like this:
select max(grade) from TableA group by tableBID
However, I don't just want the grade, I want the grade plus id of that row.