Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+22 more

    sql query architect

    2

    Translates natural language business questions into optimized, schema-verified SQL for major data warehouses.

    $19.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    3 installsSecurity scanned
    sql query architect

    sql query architect

    Example session with this skill installed

    Write a Snowflake query for monthly logo churn in 2024. Use the subscriptions table. I need to see the SQL and an explanation of the logic.

    • Read your context and instructions
    • Compiled the sql query architect

    I will generate a Snowflake-optimized query for monthly logo churn.

    Assumptions & Logic:
    *

    Logo Churn: Defined as the count of unique customers whose subscription ended (end_date) within a given month.

    • Timeframe: Limited to the calendar year 2024.

    Schema: Based on the subscriptions table. I am assuming columns customer_id, start_date, and end_date exist based on standard patterns.

    Monthly Logo Churn Query (Snowflake)

    WITH monthly_spine AS (
      -- Generate a spine of months for 2024 to ensure we see months with zero churn
      SELECT 
        DATE_TRUNC('MONTH', DATEADD('MONTH', SEQ4(), '2024-01-01')) AS report_month
      FROM TABLE(GENERATOR(ROWCOUNT => 12))
    ),
    churned_customers AS (
      SELECT 
        DATE_TRUNC('MONTH', end_date) AS churn_month,
        COUNT(DISTINCT customer_id) AS churned_count
      FROM subscriptions
      WHERE end_date >= '2024-01-01' 
        AND end_date <= '2024-12-31'
      GROUP BY 1
    )
    SELECT 
      s.report_month,
      COALESCE(c.churned_count, 0) AS logo_churn
    FROM monthly_spine s
    LEFT JOIN churned_customers c ON s.report_month = c.churn_month
    ORDER BY 1 ASC;
    

    Explanation:
    1.

    monthly_spine: Creates a list of all 12 months in 2024. This ensures that if a month has zero churn, it still appears in your report.
    2.

    churned_customers: Filters the subscriptions table for rows where the end_date falls in 2024, then groups them by month to count unique customers.
    3.

    Final Join: Combines the month list with the churn counts. I used a LEFT JOIN and COALESCE to turn missing data into a 0 for cleaner reporting.

    Next steps

    • Verify if end_date is the correct column for churn (vs. a status column).
    • Run this in your Snowflake worksheet to confirm results.
    • Provide your DDL if you want me to adjust for specific column names like sub_id or termination_dt.

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

    About this skill

    The problem

    Translating business questions into SQL often leads to broken queries due to guessed column names or misunderstood metric definitions like "churn" and "active user." Non-technical stakeholders struggle to verify if the logic matches their intent, while developers waste time fixing syntax for specific warehouse dialects.

    What it does

    • Introspects real database schemas to ensure table and column names are 100% accurate before writing a single line of code.
    • Resolves business ambiguity by defining metrics (e.g., logo vs. revenue churn) and time grains before generating SQL.
    • Generates optimized, read-only SQL queries using CTEs, defensive aggregation, and dialect-specific functions for Snowflake, BigQuery, Postgres, and more.
    • Explains technical query logic in plain English for non-technical stakeholders to review and approve.
    • Optionally executes queries against connected warehouses to return cited, verifiable results.

    Frameworks & tools

    Supports Snowflake, BigQuery, Databricks, PostgreSQL, MySQL, and standard ANSI SQL. Integrates with database connectors and semantic layers for schema discovery.

    Why this beats prompting it yourself

    Generic LLMs often hallucinate schema details or use incorrect date functions for your specific warehouse. This skill enforces a "schema-first" workflow, running discovery queries on string values and using defensive math like NULLIF to prevent runtime errors that manual prompts frequently overlook.

    Use cases

    • Generating complex MRR movement and cohort retention queries for finance teams.
    • Building funnel conversion reports from raw event logs without manual schema mapping.
    • Converting legacy SQL queries from one dialect to another, such as Postgres to BigQuery.
    • Providing a self-service data interface for PMs that outputs both the answer and the verifiable code.

    Known limitations

    Strictly read-only; will not perform DDL, DML, or data migrations. Requires an active connector or provided DDL to function without hallucinations.

    How to use

    Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    3 installs

    Downloaded by developers to date

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scanned

    Verified clean 1 month ago

    • Passed all security checks, Safe to install

    Listed1 month ago

    What's inside

    Frequently Asked Questions