From 43b718db0c9e256277102ad09049a703245be53c Mon Sep 17 00:00:00 2001 From: smallkun Date: Thu, 20 Mar 2025 16:45:59 +0800 Subject: [PATCH] Auto commit --- 2208/存储过程练习题.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/2208/存储过程练习题.md b/2208/存储过程练习题.md index 2d64d98..6ca6ad5 100644 --- a/2208/存储过程练习题.md +++ b/2208/存储过程练习题.md @@ -319,10 +319,30 @@ CALL get_employee_years_of_service(1); 创建一个存储过程 `get_department_employee_count`,接受部门ID作为参数,返回该部门的员工总数。 +```sql +DELIMITER $$ +DROP PROCEDURE IF EXISTS get_department_employee_count; +CREATE PROCEDURE get_department_employee_count(IN id INT) +BEGIN + SELECT COUNT(*) + FROM employee e + WHERE e.dept_id = id; +END $$ +DELIMITER ; +CALL get_department_employee_count(1); +``` + + + #### 练习题 11: 查询职位员工总数 创建一个存储过程 `get_job_employee_count`,接受职位ID作为参数,返回该职位的员工总数。 +```sql +``` + + + #### 练习题 12: 查询员工详细信息 创建一个存储过程 `get_employee_details`,接受员工ID作为参数,返回该员工的姓名、工资、部门名称和职位名称。