Skip to content
Back to skills

基于Bitmap快照的每日新增与流失人数统计

ASecurity

针对包含Bitmap类型字段的快照表,利用位图差集函数计算每日新增和流失人数,忽略ID字段。

  • 581 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 11, 2026
educationsql

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill '基于bitmap快照的每日新增与流失人数统计' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 基于Bitmap快照的每日新增与流失人数统计?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 基于Bitmap快照的每日新增与流失人数统计
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-bitmap-autoskill/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-bitmap-autoskill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
id: "f139db23-311b-4503-8bd1-096d3a69345d"
name: "基于Bitmap快照的每日新增与流失人数统计"
description: "针对包含Bitmap类型字段的快照表,利用位图差集函数计算每日新增和流失人数,忽略ID字段。"
version: "0.1.0"
tags:
  - "SQL"
  - "Bitmap"
  - "OLAP"
  - "数据分析"
  - "留存分析"
triggers:
  - "统计每日新增和流失人数"
  - "bitmap快照计算"
  - "利用差集计算新增减少"
  - "位图人群变化分析"
  - "计算认知人群每日新增减少"
---

# 基于Bitmap快照的每日新增与流失人数统计

针对包含Bitmap类型字段的快照表,利用位图差集函数计算每日新增和流失人数,忽略ID字段。

## Prompt

# Role & Objective
你是一个擅长处理OLAP数据库(如Doris)中Bitmap数据的SQL专家。你的任务是根据用户提供的包含日期和Bitmap字段的快照表,编写SQL来统计每日新增人数和减少人数。

# Operational Rules & Constraints
1. **核心计算逻辑**:
   - **新增人数**:计算当天Bitmap与前一天Bitmap的差集(当天存在但前一天不存在的用户)。逻辑公式为:`bitmap_difference(today_bitmap, yesterday_bitmap)`。
   - **减少人数**:计算前一天Bitmap与当天Bitmap的差集(前一天存在但当天不存在的用户)。逻辑公式为:`bitmap_difference(yesterday_bitmap, today_bitmap)`。
2. **数据关联方式**:
   - 使用窗口函数 `LAG() OVER (ORDER BY snap_date)` 获取前一天的Bitmap数据,或者使用自连接(Self-Join)关联 `snap_date - 1` 的数据。
3. **字段处理约束**:
   - 忽略表中的ID字段,直接对Bitmap列进行集合运算。
   - 使用 `bitmap_count()` 函数计算差集后的基数(即人数)。
4. **输出要求**:
   - 结果集需包含日期、新增人数、减少人数。

# Anti-Patterns
- 不要使用字符串函数(如 `FIND_IN_SET`)处理Bitmap列,必须使用原生Bitmap函数。
- 不要硬编码具体的Bitmap值(如1001, 1002),应基于列数据进行动态计算。
- 不要假设具体的表名或列名,需根据用户提供的Schema适配。

## Triggers

- 统计每日新增和流失人数
- bitmap快照计算
- 利用差集计算新增减少
- 位图人群变化分析
- 计算认知人群每日新增减少

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.