Skip to content
Datablare
Claude Code E-commerce Product & marketing

Product performance and returns

41,246 units sold this year with a 9.6% return rate; Footwear and Apparel are returned most, and Classic Headphones leads revenue.

Data
Synthetic e-commerce demo data (PostgreSQL)
Asked in
Claude Code
Updated
Try this on your data

1 · The brief

What Claude Code was asked

Which products are carrying the store, and where do returns hurt? I want units and revenue this year, the return and cancellation rates, the top ten products by revenue, return rates by category, and how returns have moved month by month.

Given exactly like this. Claude Code asked Datablare which tables it could read, wrote the SQL itself, ran each query through Datablare and built the dashboard from what came back.

2 · The dashboard

The dashboard Claude Code built

Product performance and returns dashboard: Top ten products by revenue, Return rate by category, Return and cancellation rates per month

Built from 4 read-only queries. Every figure on the dashboard was read from the database through Datablare; nothing was estimated or typed in.

Headline numbers (January–October 2026):

  • Units sold: 41,246 (Completed orders, 2026)
  • Products sold: 180 (With at least one sale)
  • Return rate: 9.6% (Orders returned)
  • Cancellation rate: 3.9% (Orders cancelled)

What stands out:

  • Top ten products by revenue: Classic Headphones leads with ₹252.4K from 516 units
  • Return rate by category: Footwear and Apparel are returned most: sizing
  • Return and cancellation rates per month: Returns ranged from 7.6% to 11.8% a month

The data is a synthetic e-commerce dataset made for this example, so the numbers describe no real company. The queries, the dashboard and the audit entries are real: Claude reached the database only through Datablare, read-only, and every query is on record with the question it served.

3 · What Datablare ran

4 read-only queries, nothing changed

Each query below is copied from the audit log of this run. Datablare checked that it only reads, ran it read-only, and gave only the rows to Claude Code; it never stores them.

  1. Query 1

    Units sold, products sold, return rate and cancellation rate for 2026 orders

    1 row · 114 ms

    SELECT sum(i.quantity) FILTER (WHERE o.status = 'completed') AS units_sold,
           count(DISTINCT i.product_id) FILTER (WHERE o.status = 'completed') AS products_sold,
           round(count(DISTINCT o.id) FILTER (WHERE o.status = 'returned')::numeric / count(DISTINCT o.id), 4) AS return_rate,
           round(count(DISTINCT o.id) FILTER (WHERE o.status = 'cancelled')::numeric / count(DISTINCT o.id), 4) AS cancellation_rate
    FROM ecommerce.orders o
    JOIN ecommerce.order_items i ON i.order_id = o.id
    WHERE o.order_date >= DATE '2026-01-01'
  2. Query 2

    Top ten products by revenue from completed orders in 2026

    10 rows · 86 ms

    SELECT p.name, p.category, sum(i.quantity) AS units, round(sum(i.quantity * i.unit_price), 0) AS revenue
    FROM ecommerce.order_items i
    JOIN ecommerce.orders o ON o.id = i.order_id
    JOIN ecommerce.products p ON p.id = i.product_id
    WHERE o.status = 'completed' AND o.order_date >= DATE '2026-01-01'
    GROUP BY 1, 2
    ORDER BY 4 DESC
    LIMIT 10
  3. Query 3

    Share of 2026 order lines that were returned, by category

    6 rows · 96 ms

    SELECT p.category, count(*) AS order_lines,
           round(avg(CASE WHEN o.status = 'returned' THEN 1.0 ELSE 0 END), 4) AS return_rate
    FROM ecommerce.order_items i
    JOIN ecommerce.orders o ON o.id = i.order_id
    JOIN ecommerce.products p ON p.id = i.product_id
    WHERE o.order_date >= DATE '2026-01-01'
    GROUP BY 1
    ORDER BY 3 DESC
  4. Query 4

    Monthly return and cancellation rates since January 2025

    22 rows · 77 ms

    SELECT to_char(date_trunc('month', order_date), 'YYYY-MM') AS month,
           round(avg(CASE WHEN status = 'returned' THEN 1.0 ELSE 0 END), 4) AS return_rate,
           round(avg(CASE WHEN status = 'cancelled' THEN 1.0 ELSE 0 END), 4) AS cancellation_rate
    FROM ecommerce.orders
    GROUP BY 1
    ORDER BY 1
Tables read ecommerce.order_itemsecommerce.ordersecommerce.products

4 · The audit entry

Who asked what, on record

Every query is recorded with the person who asked, the question in their words and why the agent ran it. Admins see this in the audit log; nothing reaches the database without it.

How the audit log works

query_data_source

via Claude Code

Allowed
Who
The person signed in (hidden on this public page)
Question
Which products are carrying the store, and where do returns hurt? I want units and revenue this year, the return and cancellation rates, the top ten products by revenue, return rates by category, and how returns have moved month by month.
Intent
Units sold, products sold, return rate and cancellation rate for 2026 orders
Result
4 queries, 39 rows, read-only

More use cases

All examples
  • E-commerce sales and retention dashboard dashboard: Monthly revenue, Revenue by category, 2026, Lifetime revenue per customer, by channel, Orders per month
    Claude Code E-commerce Executive overview

    E-commerce sales and retention dashboard

    ₹5.21M revenue from 11,897 orders this year, a 57.9% repeat-customer rate, and which channels bring the customers who spend most.

    Updated Open

  • Customer retention by first-order cohort dashboard: New and returning revenue per month, Back for a second order, by first-order quarter, New customers per quarter
    Claude Code E-commerce Customer analytics

    Customer retention by first-order cohort

    2,856 new customers this year, 76.1% of revenue from returning customers, and a median 139 days to a second order.

    Updated Open

  • Customer activity by city and segment dashboard: Active customers per month, Approved value by city, 2026, Spend per active customer per month, Customers by city and risk level
    Claude Code Banking Customer analytics

    Customer activity by city and segment

    2,277 of 3,000 customers active this year, spend per active customer each month, value by city, and the risk mix in each city.

    Updated Open

Build this on your own data.

Connect your database, choose the tables Claude may read, and give it the same brief. Claude is connected in about two minutes.

30 minutes with the founder. Or WhatsApp / [email protected]