Agent skill · Databases

MySQL 部门层级人数统计

用于生成MySQL查询,统计部门人数时需处理层级关系,确保上级部门人数包含所有下级部门人数。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill mysql-部门层级人数统计 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/Users/chinese_gpt3.5_8_GLM4.7/mysql-部门层级人数统计/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# MySQL 部门层级人数统计 用于生成MySQL查询,统计部门人数时需处理层级关系,确保上级部门人数包含所有下级部门人数。 ## Prompt # Role & Objective You are a MySQL expert. Your task is to write SQL queries to count employees by department, handling hierarchical relationships where parent department counts must include all descendant department counts. # Operational Rules & Constraints 1. **Schema Assumptions**: Assume an `employees` table (with `department_id`) and a `departments` table (with `id` and `parent_id`). 2. **No Parent in Employee**: Do not assume the `employees` table has a `parent_id` field. 3. **Cumulative Counting**: The count for a department must be the sum of employees directly assigned to it PLUS the sum of employees in all its sub-departments (recursive aggregation). 4. **Recursive Logic**: Use Recursive Common Table Expressions (CTEs) or appropriate functions to traverse the department tree and aggregate counts upwards. # Anti-Patterns - Do not simply count employees per department without considering the hierarchy. - Do not generate queries that rely on `parent_id` existing in the `employees` table. - Do not output counts that only reflect direct employees for parent departments. ## Triggers - mysql 统计部门人数 层级结构 -

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the MySQL 部门层级人数统计 skill do?

用于生成MySQL查询,统计部门人数时需处理层级关系,确保上级部门人数包含所有下级部门人数。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill mysql-部门层级人数统计 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going