跳到正文
Skillpedia
数据库47k · #6317

sql-reporting

它能做什么

这份清单指导你的智能体编写从数据仓库中提取指标或报告的 SQL。适合分析师,以及需要从数据库表中获取可靠数字的人。

适用场景

  • ✓当你需要从仓库表中提取指标、报告或仪表板数字的时候。
  • ✓当查询需要汇总计数、总和或滚动窗口的时候。
  • ✓当报告需要把两个或更多表的数据合并在一起的时候。

技能链接

https://github.com/apache/airflow/blob/main/providers/common/ai/src/airflow/providers/common/ai/example_dags/skills/sql-reporting/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/apache/airflow/blob/main/providers/common/ai/src/airflow/providers/common/ai/example_dags/skills/sql-reporting/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请编写一个查询,从我们的仓库表中按地区统计本月的订单数量。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会遵循一组固定的约定,例如先按日期过滤,并为每个汇总项命名。它会用一份简短的检查清单核对查询,然后返回 SQL 以及一句话的说明。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

<!-- SPDX-License-Identifier: Apache-2.0 https://www.apache.org/licenses/LICENSE-2.0 -->

SQL Reporting Skill

Apply this skill before writing or running any analytics SQL so reports stay consistent and safe.

When to Use This Skill

Use this skill when the task involves:

  • Querying warehouse tables for a metric, report, or dashboard figure
  • Aggregating rows (counts, sums, rolling windows)
  • Cross-referencing two or more tables

Conventions

  1. Always SELECT explicit column names, never SELECT *.
  2. Filter on a partition/date column first to bound the scan.
  3. Alias aggregates with snake_case names (order_count, not count(*)).
  4. Cap exploratory queries with LIMIT unless an aggregate already collapses the result set.
  5. Prefer COUNT(DISTINCT ...) over a sub-query when de-duplicating.

Review Checklist (run before returning an answer)

  • No SELECT *.
  • A date or partition predicate is present.
  • Every aggregate has an explicit alias.
  • The query reads only from tables the task actually needs.

Output Format

Return the final SQL in a fenced ```sql block, then one sentence describing what the query returns.

常见问题

为什么避免使用 SELECT *?

该技能说明,应列出明确的列名,这样查询更清晰,也更容易检查。

它会限制查询读取的数据量吗?

会。它要求先按日期或分区列过滤,并为探索性查询添加限制。

答案是什么样子的?

最终的 SQL 会以代码块形式呈现,后面跟一句话,说明查询返回什么内容。

详情

作者的原始描述

Conventions and review steps for writing analytics SQL against the warehouse. Use whenever the task involves querying tables, building a report, or aggregating metrics.

repo: apache/airflow

热度

GitHub 星标
47k
排名
#6317
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

相似技能