Select count(course),course,dept, Case When ****condition*** then 'passed' Else 'failed' End as finalstatus from college group by course,dept;
Here condition should check each subject of each student if any student fails atleast one subject then final status should be failed or if student passes all subjects then final status should be passed