创建存储过程p_CourseNum,能根据用户给定的课程名称统计学习这门课程的人数
时间: 2024-02-01 11:15:29 浏览: 151
好的,以下是实现该需求的存储过程p_CourseNum的代码:
```
CREATE PROCEDURE p_CourseNum
@course_name VARCHAR(50)
AS
BEGIN
SELECT COUNT(*) AS [Number of Students]
FROM student_course
WHERE course_name = @course_name
END
```
该存储过程接收一个参数 @course_name,表示要统计人数的课程名称。在存储过程中,我们通过查询 student_course 表,筛选出课程名称为 @course_name 的记录,并使用 COUNT(*) 函数统计人数。最终将结果集返回给调用方。
你可以根据自己的实际表结构和数据来调整该存储过程。
阅读全文
相关推荐















