给定以下查询,它将计算给定入学(科目)姓氏史密斯的学生人数
SELECT
e.EnrolmentId,
COUNT((CASE WHEN s.Surname LIKE 'Smith' THEN 1 ELSE NULL END)) AS CountIf
FROM
Enrolment e
INNER JOIN StudentEnrolment se
ON e.EnrolmentId = se.EnrolmentId
INNER JOIN Student s
ON se.StudentId = s.StudentId
GROUP BY
e.EnrolmentId
是否可以将“史密斯”作为参数,像这样
COUNT((CASE WHEN s.Surname LIKE @Surname THEN 1 ELSE NULL END)) AS CountIf