sql 中的总计数

Total count in sql

我需要创建一个视图来显示已申报两个专业的学生总数(Major1Major2 不为空)。

我应该使用什么查询?

我的目标是获得单行输出,因此我知道 ORDER BY 子句在这种情况下无关紧要。

像这样:

    CREATE VIEW GetNumberOfStudentswithMajor

    AS

    SELECT COUNT(*) FROM dbo.Students where Major1 is not null and Major2 is not null