sql - getting the id from a row based on a group by
        Posted  
        
            by user85116
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user85116
        
        
        
        Published on 2010-04-06T20:34:29Z
        Indexed on 
            2010/04/06
            20:43 UTC
        
        
        Read the original article
        Hit count: 219
        
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.
© Stack Overflow or respective owner