Home > database >  A student table, a result table, result in the table has each student m course grades, more than 60
A student table, a result table, result in the table has each student m course grades, more than 60

Time:09-18

Two tables associated query SQL can't write, consult!!!!!!
A student table, a result table, result in the table has each student m course grades, more than 60 points and calculate the query pass & gt;=0.5 the number of students

CodePudding user response:

Select the student
The result for the from
Group by student
Having the sum (case when mark & gt; 60 then 1 else 0=end) & gt; Count (*)/2

CodePudding user response:

Thank @ sell fruit net, see having usage is a sobering, educated, the final statement below
SELECT count (*) FROM (SELECT student_name FROM SUBJECT GROUP BY student_name HAVING sum (CASE WHEN subject_status=1 THEN 1 ELSE 0 END) & gt; T count (*) * 0.75)
  • Related