user3392695
user3392695

Reputation: 21

Student who passed in at-least 1 or more subjects

I have a student table with all details of student as below

enter image description here

Marks table as below

enter image description here

How can i get the students who have passed(35+ Marks) in atleast 1 or more subjects Which means Result shall not show Student NO 1 as he failed in all subjects. Group by dosent seems to work as it may pull Student No 2 also.

Upvotes: 0

Views: 766

Answers (2)

Keron Tzul
Keron Tzul

Reputation: 73

I think something like this might work too ?

 Select student.fname,student.lname  from students inner join marks on marks.sid = 
 student.id where marks >= 35;

Upvotes: 0

Cetin Basoz
Cetin Basoz

Reputation: 23867

It would be like:

select * 
from students
where exists (select * from 
marks where marks.sid = students.id and marks.mark >= 35);

Note: Group By too would work. You could group by student id and get MAX(Mark) to compare if that is >= 35.

Upvotes: 3

Related Questions