I've been trying to solve the following problem:
Write a query to display list of subject names and minimum mark scored in 'Software Engineering' and 'Computer Programming' . Give an alias name as MIN_MARK for minimum mark column. Sort the result based on subject name in descending order.
And this is the code I've tried to solved the aforementioned problem:
select s.subject_name, min (m.value) as MIN_MARK
from mark m
join subject s on m.subject_id = s.subject_id
where m.subject_id in (select subject_id from subject
where subject_name = 'Software Engineering'
and subject_name='Computer Programming')
group by s.subject_name;
And I'm getting the output --> No Rows Selected
Could anyone please tell me how to solve this problem.
CodePudding user response:
Could you please tell me what was the issue?
As I mentioned in the comment the problem is the where filter.
where subject_name = 'Software Engineering'
and subject_name = 'Computer Programming'
Can the same row be 'Software Engineering' and 'Computer Programming' simultaneously ?
Answer. No
You have to change the where filter from and
to or
(which ca be written easily as in) .
where subject_name in ('Software Engineering','Computer Programming')