- Home
- Skills
- Data & Databases
- SQL row multiplicity review
SQL row multiplicity review
For data analysts: a grain analysis and correctness test cases.
$12
Works with the AI Agents you already use
SQL row multiplicity review
Example session with this skill installed
Use the skill to produce a grain analysis and correctness test cases. Input S1: orders has id=1,total=100. items has two rows for order 1. Query joins then SUM(orders.total). Desired total sales is 100.
- Read your context and instructions
- Compiled the sql row multiplicity
Synthetic test example. Recorded AI smoke-test response. No real service changes were executed.
The join changes the grain from one row per order to one row per item, duplicating the order total. This is a hand calculation from S1, not a query execution.
Intended grain: count each order.total once, then aggregate total sales.
Synthetic counterexample already supplied: orders (id=1,total=100); items (order_id=1,item=a) and (order_id=1,item=b). Joining produces two rows with total 100 each; SUM is 100 + 100 = 200, contradicting the desired 100.
Proposed rewrite if all orders count
SELECT SUM(total) AS total_sales FROM orders;
If only orders having items should count, use an existence predicate:
SELECT SUM(o.total) AS total_sales
FROM orders o
WHERE EXISTS (SELECT 1 FROM items i WHERE i.order_id = o.id);
Do not use SUM(DISTINCT total), since two different orders may share the same total.
Proposed cases: one order with two items -> 100; two orders each total 100 -> 200; zero-item order -> outcome depends on inclusion contract; empty orders -> decide whether NULL or 0 is required.
Missing inputs: exact SQL, filters, cardinality constraints, zero-item and empty-set rules. Performance is unmeasured.
Acceptance check: vary item counts without changing order totals; qualifying-order sales must remain unchanged.
Connects securely to your tools. The creator never sees your data.
About this skill
Use this skill when you have SQL, schema cardinalities and intended output grain and need a grain analysis and correctness test cases.
The workflow:
- Declare the intended grain before inspecting joins.
- Trace one-to-many relationships and aggregates that can multiply rows.
- Build a tiny synthetic counterexample and calculate expected rows or sums.
- Propose a grain-preserving rewrite and separate correctness from unmeasured performance.
You receive the work product with input-linked findings, visible unknowns and concrete verification checks. Work from pasted or redacted text. This skill does not execute changes, send messages or access service accounts.
Original AI-assisted content. A synthetic worked example is included. Use through your Agensi-connected agent. No extra paid API or runtime is required for this workflow. Delivery is through the Agensi agent connection. No sales, ranking or compliance outcome is promised.
How to use
- 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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
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
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 8 days ago
Permissions
No special permissions declared or detected