我搜索了它,但我找不到正确的答案.
Student
------------------
rollno int PK
name varchar(20)
class varchar(20)
另一张桌子是
Marks
-----------------
rollno FK
sub1 int
sub2 int
sub3 int
sub4 int
sub5 int
sub1,sub2等包含主题的标记.现在我想要一个查询,它将显示在超过2个科目中有> 35分的学生信息?
最佳答案
select rollno,
case when sub1 < 35 then 0 else 1 end +
case when sub2 < 35 then 0 else 1 end +
case when sub3 < 35 then 0 else 1 end +
case when sub4 < 35 then 0 else 1 end +
case when sub5 < 35 then 0 else 1 end +
end
as [Count]
from student,marks where count > 2