Sql Query Optimazation


I have this query

and i want to optimize this query (here I use a SELECT and SUB SELECT) and use only one SELECT if possible

Does anyone have any Idea about it.

Thank you in advance


FROM course AS c

JOIN student_course AS sc

ON c.id = uc.course_id

WHERE sc.student_id = '5' AND c.level = (SELECT MAX(level) 

                                         FROM course  

                                         JOIN student_course 

                                         ON c.id = sc.course_id)

GROUP BY c.category_id 


It’s possible. What Database are you using?

Can You provide sql create tables and inserts(exemples) for the case?