Revenue is vanity, net is reality. This query combines order revenue, FBA fulfillment fees, referral fees, and returns to show what you're actually keeping on each product.
The question
The SQL Taptic generates
WITH revenue AS ( SELECT i.sku, MAX(i.product_name) AS product_name, SUM(i.item_price * i.quantity) AS gross_revenue, SUM(i.quantity) AS units_sold FROM amazon_order_items i JOIN amazon_orders o ON o.amazon_order_id = i.amazon_order_id WHERE o.order_status NOT IN ('Canceled', 'Cancelled') AND i.item_price IS NOT NULL AND o.purchase_date::date >= CURRENT_DATE - INTERVAL '90 days' GROUP BY i.sku ), fees AS ( SELECT seller_sku AS sku, SUM(item_related_fee_amount) AS total_fees FROM amazon_financial_events WHERE charge_type IN ('FBAPerUnitFulfillmentFee', 'Commission') AND posted_date::date >= CURRENT_DATE - INTERVAL '90 days' GROUP BY seller_sku ), returns_cost AS ( SELECT sku, COUNT(*) * AVG(f.estimated_referral_fee_per_unit) AS estimated_return_cost FROM amazon_returns r JOIN amazon_fba_fees f USING (sku) WHERE r.return_date::date >= CURRENT_DATE - INTERVAL '90 days' GROUP BY r.sku ) SELECT r.sku, r.product_name, r.gross_revenue, COALESCE(f.total_fees, 0) AS total_fees, COALESCE(rc.estimated_return_cost, 0) AS estimated_return_cost, r.gross_revenue - COALESCE(f.total_fees, 0) - COALESCE(rc.estimated_return_cost, 0) AS estimated_net, ROUND( (r.gross_revenue - COALESCE(f.total_fees, 0) - COALESCE(rc.estimated_return_cost, 0)) / NULLIF(r.gross_revenue, 0) * 100, 2 ) AS net_margin_pct FROM revenue r LEFT JOIN fees f USING (sku) LEFT JOIN returns_cost rc USING (sku) WHERE r.units_sold > 5 ORDER BY estimated_net DESC
This query was generated by Taptic Data from plain English against a real Amazon Seller Central schema. In Taptic, you type the question — the AI writes the SQL, runs it, and returns the result. You can edit the SQL, ask for explanations, and save it as a refreshable report.
How this query works
What it returns
A ranked table showing each SKU's gross revenue, total fees, estimated return costs, estimated net revenue, and net margin percentage — sorted by highest absolute net to find your most profitable products.
Why it matters
Generate this automatically
In Taptic Data, you type "Show me net margin per SKU after FBA fees, referral fees, an..." and this SQL runs automatically against your real Amazon Seller Central data.
Try Taptic Free — $29.99/moNo credit card required. Connect your data source in under 5 minutes.