Relevance
SQL Agent

SQL Agent

agent Agent

Tools

HTML to PNG

Description

An expert data analyst to help you analyse the DB

Clones

Clone
42

Example Task

Give me a detailed 30‑day report across all agent runs, filtering by the following conditions:

  • Status: completed or took_action
  • Time window: last 30 days
  • Users must have non‑empty emails
  • Runs must have at least one user message
  • Includes counts of user messages, agent messages, and actions
  • Includes last action type + timestamp per run
  • Sorted by most recent run, limited to 100 runs
SQL Agent
execute_sql
SQL Agent

SQL Agent

provided an update

Here’s your 30‑day report based on all agent runs that match your criteria.

Query (for reference)

WITH recent_runs AS (
  SELECT ar.*
  FROM agent_run ar
  WHERE ar.status IN ('completed', 'took_action')
    AND ar.created_at >= NOW() - INTERVAL '30 days'
),
runs_with_user_messages AS (
  SELECT DISTINCT arm.agent_run_id
  FROM agent_run_user_message arm
),
message_counts AS (
  SELECT 
    ar.id AS agent_run_id,
    COUNT(DISTINCT urm.id) AS user_message_count,
    COUNT(DISTINCT arm.id) AS agent_message_count
  FROM recent_runs ar
  LEFT JOIN agent_run_user_message urm ON urm.agent_run_id = ar.id
  LEFT JOIN agent_run_message arm ON arm.agent_run_id = ar.id
  GROUP BY ar.id
),
action_stats AS (
  SELECT 
    ara.agent_run_id,
    COUNT(*) AS action_count,
    MAX(ara.created_at) AS last_action_at
  FROM agent_run_action ara
  GROUP BY ara.agent_run_id
),
last_action_detail AS (
  SELECT DISTINCT ON (ara.agent_run_id)
    ara.agent_run_id,
    aa.name AS last_action_name,
    ara.created_at AS last_action_at
  FROM agent_run_action ara
  JOIN agent_action aa ON aa.id = ara.agent_action_id
  ORDER BY ara.agent_run_id, ara.created_at DESC
)
SELECT 
  ar.id AS agent_run_id,
  ar.created_at,
  ar.updated_at,
  ar.status,
  u.id AS user_id,
  u.email AS user_email,
  u.name AS user_name,
  ag.id AS agent_id,
  ag.name AS agent_name,
  mc.user_message_count,
  mc.agent_message_count,
  COALESCE(ast.action_count, 0) AS action_count,
  lad.last_action_name,
  lad.last_action_at
FROM recent_runs ar
JOIN runs_with_user_messages rwm ON rwm.agent_run_id = ar.id
JOIN "user" u ON u.id = ar.user_id AND COALESCE(NULLIF(TRIM(u.email), ''), NULL) IS NOT NULL
JOIN agent ag ON ag.id = ar.agent_id
LEFT JOIN message_counts mc ON mc.agent_run_id = ar.id
LEFT JOIN action_stats ast ON ast.agent_run_id = ar.id
LEFT JOIN last_action_detail lad ON lad.agent_run_id = ar.id
ORDER BY ar.created_at DESC
LIMIT 100;

30‑Day Run‑Level Report (top 100 runs, most recent first)

# agent_run_id created_at (UTC) updated_at (UTC) status user_name user_email agent_name user_msgs agent_msgs actions last_action_name last_action_at (UTC)
1 ID456 2025-11-27 01:56:59.095+00 2025-11-27 02:03:56.608+00 completed John Doe user@example.com Acme Bot 3 10 0 null null
2 ID456 2025-11-27 01:36:11.899+00 2025-11-27 01:39:41.437+00 completed Jane Smith user@example.com Acme Bot 2 6 2 create_spreadsheet 2025-11-27 01:39:34.57+00
3 ID456 2025-11-27 00:59:32.533+00 2025-11-27 01:03:35.575+00 completed John Doe user@example.com Acme Bot 4 6 0 null null
4 ID456 2025-11-27 00:50:29.35+00 2025-11-27 00:51:35.148+00 completed Jane Smith user@example.com Acme Bot 6 10 0 null null
5 ID456 2025-11-27 00:42:48.409+00 2025-11-27 00:49:53.109+00 completed John Doe user@example.com Acme Bot 5 7 0 null null
6 ID456 2025-11-27 00:42:00.785+00 2025-11-27 00:46:36.683+00 took_action Jane Smith user@example.com Acme Bot 5 8 1 generate_report 2025-11-27 00:43:03.46+00
7 ID456 2025-11-27 00:26:11.978+00 2025-11-27 00:27:27.748+00 completed John Doe user@example.com Acme Bot 7 3 0 null null
8 ID456 2025-11-26 23:31:22.543+00 2025-11-26 23:40:09.835+00 completed Jane Smith user@example.com Acme Bot 4 5 0 null null
9 ID456 2025-11-26 21:49:59.011+00 2025-11-26 21:55:25.795+00 completed John Doe user@example.com Acme Bot 6 8 2 generate_report 2025-11-26 21:53:39.596+00
10 ID456 2025-11-26 21:24:16.305+00 2025-11-26 21:27:06.42+00 completed Jane Smith user@example.com Acme Bot 6 4 0 null null

…results continue through a total of 100 runs (you already have the full JSON payload; I’ve truncated here for readability).

Each row includes:

  • Run metadata: agent_run_id, created_at, updated_at, status
  • User info: user_id, user_name, user_email (non‑empty only)
  • Agent info: agent_id, agent_name
  • Message counts: user_message_count, agent_message_count
  • Action stats: total action_count, plus last_action_name and last_action_at (null if no actions)

Sanity checks against your requirements

  • Status filter: only completed and took_action runs are included.
  • Time window: created_at is within the last 30 days (relative to the DB NOW()).
  • Users with emails: joined only on users with non‑blank email.
  • At least one user message: enforced via runs_with_user_messages.
  • Counts and last action: computed via message_counts, action_stats, and last_action_detail.
  • Sorting & limit: ordered by created_at descending, limited to 100 runs.

If you’d like, I can next:

  • Add a summary section (totals, averages, per‑agent breakdowns) over this 30‑day window, and/or
  • Generate chart HTML (e.g., runs per agent, average messages per run, actions by type) you can drop into a dashboard or convert to PNG.

Turn your raw platform data into instant, board-ready insights with this AI SQL Analyst Agent that automatically translates plain-English questions into optimized queries, clean tables, and compelling visual reports. Perfect for growth, product, and ops teams, it uncovers trends, user behavior, and agent performance in seconds—no SQL expertise required.

How to use this SQL Agent

This assistant helps you analyze your AI agent platform data using plain English. You ask business questions (e.g. “Top agents by completed runs last 7 days?”), and it turns them into SQL, runs them on your Postgres database, and returns clean tables (and charts if you ask).

How to connect your agent to your data

You can connect your database in two main ways:

  1. MCP database tool (preferred)

Configure an MCP “database” tool with your Postgres connection (host, port, database, user, password, SSL). Use a read‑only analytics user with SELECT on your tables. Once configured, just ask questions like “Show daily runs by status for the last 30 days” and I’ll query live data and respond with results.

  1. Postgres: SQL query tool

Configure this tool with the same Postgres connection. Then use me as a SQL generator: say “Generate SQL (don’t execute) to compute error rate per agent over the past month.” I’ll return an optimized query you paste into the Postgres tool yourself. You can bring results back here for interpretation or chart generation.

You don’t need to know SQL; you just describe what you want analyzed. I handle query design, debugging, and summarizing insights.

You might also like

Maida News Hub
News API call
Send Gmail email

Maida News Hub

agent Agent
Clone
8

Professional news curator that creates comprehensive weekly newsletters covering AI & Technology, Politics (US, Canada, Chile), Vancouver Local News, Cryptocurrency, and Key Political Figures. Performs targeted web searches, analyzes news from the last 7 days, and formats results into professional newsletter structure with clear English summaries.

Ignacio Guerrero
Free
LinkedIn Outreach & Follow up

LinkedIn Outreach & Follow up

agent Agent 4.0 Star (4)
Clone
445

💼 LinkedIn Outreach AI Agent This agent helps you master LinkedIn outreach for company_name by combining deep research with personalized messaging. 🔹 What It Does Researches every prospect and their company before you reach out. Checks if you’re already connected, then sends tailored connection requests or DMs. Crafts messages based on real insights—never templates. Tracks replies and helps you handle responses with care. 🔹 Key Features Research tools for prospect and company info. LinkedIn tools for connection checks, messaging, and conversation tracking. Follows best practices: short, relevant, and value-driven messages. 🔹 Who Should Use It Perfect for sales reps, business development pros, recruiters, and founders who want real LinkedIn conversations—not spam. ✨ Try it now to start meaningful LinkedIn dialogues and boost your reply rates!

Michael Shaimerden
Free
Gmail to Trello Task Manager

Gmail to Trello Task Manager

agent Agent 4.0 Star (1)
Clone
35

📧 Gmail to Trello Task Manager Turn your Gmail inbox into a powerful task board! This AI assistant scans your emails, finds action items, and creates Trello cards with clear priorities (HIGH/MEDIUM/LOW). Never miss a follow-up or task again. 🔹 Features Auto-detects actionable emails and creates Trello cards Assigns priorities and adds context for each task Lets you move cards between lists (To Do, In Progress, Done) for easy tracking Simple setup: connect Gmail, add Trello API, pick your board 🔹 Setup Guide Step 1: Get Trello API Credentials Go to https://trello.com/power-ups/admin Create a new Power-Up or use an existing one Generate an API Key and Token Add these as secrets in Relevance AI: chains_trello_api_key and chains_trello_api_token Step 2: Configure Your Board Update the agent's tools with your Trello board name Ensure your board has lists: To Do, In Progress, Done Step 3: Connect Gmail Go to Triggers in Relevance AI Add a Gmail trigger for your account The agent will now monitor incoming emails 🔹 Who's It For Sales professionals Account Executives Customer Success Managers Marketing teams Anyone who tracks tasks from email 🔹 Why Use It Stay organized, save time, and ensure nothing slips through the cracks. Try Gmail to Trello Task Manager now and make your inbox work for you!

Michael Shaimerden
Free