Here I have several tables, which look like this:

Table SINHVIEN:

```
MaSV    HoSV         TenSV    GioiTinh      NgaySinh    NoiSinh     MaKH    HocBong     DiemTB 
SV01    Lê Kim       Lan      Nữ            23/02/1990  Hà nội      HTTT    130000  
SV02    Trần Minh    Chánh    Nam           24/12/1992  Bình Định   MANG    150000  
SV03    Lê An        Tuyết    Nữ            21/02/1991  Hải phòng   HTTT    170000  
SV04    Trần Anh     Tuấn     Nam           20/12/1993  TpHCM       MANG    80000   
SV05    Trần Thị     Mai      Nữ            12/08/1991  TpHCM       CNPM    0   
SV06    Lê Thị Thu   Thủy     Nữ            02/01/1991  An Giang    HTTT    0   
SV07    Nguyễn Kim   Thư      Nữ            02/02/1990  Hà Nội      CNPM    180000  
SV08    Lê Văn       Long     Nam           08/12/1992  TpHCM        HTTT   190000  

```

Table KETQUA:

```
Masv    MaMH    LanThi  Diem    KetQua 
SV01    CSDL    1        3  
SV01    CSDL    2        6  
SV01    TTNT    1       5.5     
SV01    TTNT    2        6  
SV01    MMT     1        5  
SV02    CSDL    1       4.5     
SV02    CSDL    2        7  
SV02    MMT     1       10  
SV02    CTDL    1        9  
SV03    CSDL    1        2  
SV03    CSDL    2        5  
SV03    MMT     1       2.5     
SV03    MMT     2        4  
SV04    CSDL    1       4.5     
SV04    CTDL    1        10     
SV05    CSDL    1        7  
SV05    MMT     1       2.5     
SV05    MMT     2        5  
SV06    TTNT    1        6  
SV06    DHMT    1       10  

```

I want to update DiemTB (which are the highest score of each student) for each student so that for each MonHoc in Sinhvien table based on the DIEM column in KETQUA table.

My code so far: 

```sql
UPDATE SINHVIEN
SET DIEMTB = T2.DIEM
FROM SINHVIEN JOIN KETQUA T2 
ON SINHVIEN.MASV = T2.MASV AND T2.DIEM = (SELECT MAX(DIEM) FROM KETQUA GROUP BY MASV)

```

I know that there is not a right way to update DIEM for each student like this because this statement `(SELECT MAX(DIEM) FROM KETQUA GROUP BY MASV)` return the highest score of each student but T2.DIEM can deal with one student at a time. 
Can you help me change modify this code so my code could update the highest score for each student in Sinhvien table based on DIEM on KETQUA table?
Thanks!