-2

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

1
  • Oracle or MySQL? Are you having an error or an unexpected result?
    – Aleksej
    Commented May 15, 2016 at 6:56

2 Answers 2

0

You need to use all columns in group by which are present in the select statement.

0
0

Assuming that your CASE condition relies on columns different from course and dept, you may need to include your CASE expression in GROUP BY clause:

Select count(course)
       course,
       dept,
       Case When ****condition*** then 
            'passed'
        Else 
            'failed'
       End as finalstatus
from college
group by course,
         dept,
         Case When ****condition*** then 
              'passed'
          Else 
              'failed'
         End;

Not the answer you're looking for? Browse other questions tagged or ask your own question.