i have a table:
STUDENT:
| STUDENT_ID | HEAD_STD_ID | STUDENT_NAME | GRADE |
and i need to select list of student_name having grades more than them head student. I tried several selection with subquery but it does not working. Can you help me?
>Solution :
Join your table with itself to get the grades of the head students next to each student, then filter out the rows where the head has the greater grade.
select u.student_name
from students as u inner join students as v
on u.head_std_id = v.student_id
where u.grade > v.grade;
