sql-analysis
Skill này làm gì
Skill này biến một câu hỏi kinh doanh thành truy vấn SQL đã được kiểm tra và một bảng kết quả nhỏ. Skill dành cho nhà phân tích và quản lý cần con số từ cơ sở dữ liệu mà không phải tự viết truy vấn.
Khi nào nên dùng
- ✓Khi bạn hỏi bao nhiêu, xu hướng ra sao hoặc các mục hàng đầu là gì trong cơ sở dữ liệu.
- ✓Khi bạn muốn so sánh hai nhóm hoặc hai khoảng thời gian bằng dữ liệu.
- ✓Khi bạn cần một bảng kết quả kèm theo truy vấn đã tạo ra nó.
Liên kết skill
https://github.com/agentscope-ai/agentscope-java/blob/main/agentscope-examples/agents/agentscope-dataagent/src/main/resources/shared/agents/data-agent/skills/sql-analysis/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Năm ngoái mỗi tháng chúng ta có bao nhiêu khách hàng mới, chia theo khu vực? Hãy cho tôi xem truy vấn và bảng kết quả.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill viết lại câu hỏi thành một chỉ số, có cách nhóm, khoảng thời gian và bộ lọc. Sau đó skill soạn câu SQL, chạy thử, kiểm tra số dòng và kết quả có hợp lý không, rồi báo lại bảng kết quả cùng truy vấn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
SQL Analysis Skill
Repeatable SOP for turning a business question into a verifiable SQL answer.
Steps
Restate the question as a metric. In one sentence, write: "<metric> by <grouping> over <time window>, filtered by <filter>". If any of those four (metric / grouping / window / filter) is missing or ambiguous, ask one clarifying question and stop. Do not guess.
Locate the source. Decide where the data lives:
- Look in
knowledge/first for any schema notes, data-dictionary entries, or prior query examples uploaded by the user. - If the right table is not obvious, delegate to the
data-explorersub-agent with the metric definition as the prompt — its job is to identify the canonical source.
- Look in
Draft the query. Write the SQL in a fenced
sqlblock. Conventions:- Always include the time window in a
WHEREclause — never query the full history "just in case". - Always
SELECTan explicit column list — neverSELECT *in an answer. - Use CTEs (
WITH x AS (...)) over nested subqueries for anything beyond two levels of nesting. - Comment any non-obvious filter (
-- excludes internal test accounts).
- Always include the time window in a
Validate before reporting. Run the query and check:
- Row count is in the ballpark you expected (1 row, 10 rows, ~30 daily buckets, etc.). A surprising row count is almost always a bug — investigate.
- No
NULLs in the grouping column unless that is the intended cohort. - At least one numeric sanity check: a known total, a known reference value, or a min/max range that matches reality.
- If anything looks off, do not report the number — fix the query first.
Write the report. Use this exact structure:
## Answer <one-sentence direct answer with the headline number(s)> ## Result <small markdown table — at most ~15 rows; for longer results, summarise and offer to render a chart or attach the full CSV> ## Query ```sql <the exact query you ran>Sources & validation
- Table(s):
schema.table_name(row count, freshness if known) - Validation: <which sanity checks you ran and the result>
- Caveats: <known data quality issues, missing dates, etc.>
- Table(s):
Anti-patterns
- ❌ Reporting a number without the query that produced it.
- ❌ Using
LIMIT Nto "make the output fit" without explaining what got cut. - ❌ Reading a single row and reporting it as a trend.
- ❌ Inventing a table or column name. If unsure, delegate to
data-explorer.
When to delegate
- The user's question requires probing several candidate tables / sources
before any query can be written → spawn
data-explorer. - The user wants a polished written deliverable summarising several analyses
(e.g. "weekly health report") → spawn
report-writerafter you have the underlying numbers ready.
Câu hỏi thường gặp
Skill có tự đoán các chi tiết còn thiếu không?
Không. Nếu chỉ số, cách nhóm, khoảng thời gian hoặc bộ lọc chưa rõ, skill sẽ hỏi lại một câu để làm rõ.
Skill có hiển thị truy vấn không?
Có. Skill trình bày câu SQL cùng với bảng kết quả.
Skill có kiểm tra kết quả không?
Có. Trước khi báo cáo, skill kiểm tra số dòng và các giá trị xem có hợp lý không.
Chi tiết
Mô tả gốc của tác giả
Answer a quantitative business question by writing a SQL query against the data warehouse, validating it, and presenting the result. Use when the user asks "how many...", "what's the trend of...", "compare X vs Y over...", "what's our top N...", or anything that resolves to a query against tabular data. Produces a small result table plus the underlying query.
Độ phổ biến
- Sao GitHub
- 6.2k
- Vị trí xếp hạng
- #14391
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentscope-java
6.2kGiúp agent của bạn viết mã Java không chặn cho AgentScope, một framework đa agent xây dựng trên Project Reactor.
data-report
6.2kGiúp agent của bạn tóm tắt một bộ dữ liệu thành báo cáo có trung bình, tổng, khoảng giá trị và xu hướng, lưu dưới dạng tệp Markdown.
data-transform
6.2kGiúp agent của bạn chuyển đổi tệp dữ liệu giữa các định dạng như CSV và JSON, để dữ liệu có thể dùng trong công cụ khác.
git-changelog
6.2kGiúp agent của bạn viết changelog hoặc ghi chú phát hành từ lịch sử Git, được nhóm thành tính năng, sửa lỗi và thay đổi khác.
Skill tương tự
discrawl
394kCho phép agent của bạn tìm kiếm và tóm tắt kho lưu trữ tin nhắn Discord trên máy, kiểm tra độ mới của dữ liệu và đọc tin nhắn trực tiếp.
clickhouse-io
280kGiúp agent của bạn tối ưu truy vấn và schema trong ClickHouse theo thực hành tốt nhất cho phân tích dữ liệu hiệu năng cao khi truy vấn chậm.
scientific-db-pubmed-database
280kGiúp agent của bạn tìm bài báo khoa học trong lĩnh vực y sinh. Hữu ích cho nghiên cứu cần thông tin y khoa cụ thể.