Works with the AI Agents you already use

    SQL Analysis Assistant

    by Syed Najaf

    1

    Write, explain, debug, and improve analytical SQL queries for database analysis and real-world business problems.

    Free

    Security scanned
    SQL Analysis Assistant

    SQL Analysis Assistant

    Example session with this skill installed

    I need a PostgreSQL query to find the top 5 customers by total spend in 2023. I have 'orders' (id, customer_id, total_price, created_at) and 'users' (id, name, email).

    • Read your context and instructions
    • Compiled the sql analysis assistant

    I will calculate the total spend per customer for the year 2023 by joining the users and orders tables, then filtering by date.

    Top 5 Customers by Spend (PostgreSQL)

    WITH customer_spending AS (
        SELECT 
            u.id AS customer_id,
            u.name AS customer_name,
            SUM(o.total_price) AS total_spend,
            COUNT(o.id) AS order_count
        FROM users u
        INNER JOIN orders o ON u.id = o.customer_id
        WHERE o.created_at >= '2023-01-01' 
          AND o.created_at < '2024-01-01'
        GROUP BY u.id, u.name
    )
    SELECT 
        customer_id,
        customer_name,
        total_spend,
        order_count
    FROM customer_spending
    ORDER BY total_spend DESC
    LIMIT 5;
    

    Explanation:

    • CTE (customer_spending): Isolates the aggregation logic to keep the final SELECT clean.
    • Inner Join: Ensures we only include users who actually placed orders.
    • Date Filtering: Uses a range (>= and <) which is generally more index-friendly than functional extraction like YEAR().
    • Grouping: Groups by both ID and Name to satisfy standard SQL requirements while ensuring uniqueness via the ID.

    Validation:

    1. Check if total_spend for a known high-value user matches their individual order history.
    2. Run a count of rows in orders for 2023 to ensure the sum of order_count in this query (without the LIMIT) matches.

    Assumptions:

    • total_price does not include currency symbols and is a numeric type.
    • created_at is a timestamp or date type compatible with standard ISO strings.

    Next steps

    • Verify if you need to exclude canceled or returned orders.
    • Determine if guest checkouts (orders with null customer_id) should be aggregated.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    SQL Analysis Assistant helps users solve analytical problems using clear and readable SQL.

    It can:

    • Write SQL queries from business questions.
    • Explain existing SQL queries step by step.
    • Debug syntax and logical errors.
    • Improve query readability and performance.
    • Explain joins, aggregations, subqueries, and CTEs.
    • Help with window functions and ranking.
    • Identify potential duplicate and join multiplication issues.

    Supports common SQL dialects such as MySQL, PostgreSQL, SQL Server, and SQLite.

    Designed for students, analysts, and professionals working with relational databases.

    Requires manual input of table schemas and column names. Does not perform low-level hardware-specific performance tuning.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 12 days ago

    • Free with an Agensi account

    Requires

    Nothing to install.

    Permissions

    Read Files
    Listed12 days ago

    What's inside

    Frequently Asked Questions

    This skill acts as a specialized logic layer for your AI agent, enforcing a rigorous verification workflow that specifically identifies potential join explosions and 'incorrect sum' errors that generic prompts often miss.

    The skill is compatible with any AI agent platform that supports custom system instructions or tool definitions, and it works across all major dialects including PostgreSQL, MySQL, BigQuery, and SQL Server.

    No, for security and privacy, the skill operates based on the schema details (table and column names) you provide manually; it does not require or maintain a direct connection to your live database.

    The skill is particularly effective for complex analytical tasks like cohort analysis, multi-table joins with disparate grains, window functions, and migrating legacy scripts between different SQL dialects.

    You receive the full SQL Analysis Assistant skill configuration, including the proprietary logic-mapping and join-validation frameworks designed to ensure query integrity.

    While the skill focuses on logical correctness and readability, it does not provide hardware-specific cost optimization or index tuning for high-scale enterprise clusters.

    New in Data & Databases

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.

    Free