You're drowning in Stripe data—charges, customers, refunds—but extracting it for custom analysis means building webhooks, exporting CSVs, or writing ETL scripts. Sigma SQL changes that. It's Stripe's built-in query tool that lets you run SQL directly against your Stripe data in the dashboard, no integration needed.
What Sigma SQL Does
Sigma is a browser-based SQL editor in your Stripe Dashboard. You write queries, get results instantly, and export them without leaving the product.
Access Sigma from the Stripe Dashboard
Open your Stripe Dashboard, navigate to Developers in the left sidebar, then select Sigma. You'll see a SQL editor with a list of queryable tables on the right side.
// You don't use the SDK to query Sigma—it's dashboard-native.
// But you can integrate results into your app via the REST API.
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
// Example: Fetch charges programmatically
const charges = await stripe.charges.list({
limit: 100,
created: {
gte: Math.floor(Date.now() / 1000) - 86400 // last 24 hours
}
});Understand the Available Tables
Sigma exposes tables for your Stripe objects: charges, customers, events, disputes, refunds, subscriptions, invoices, and more. Each table has columns corresponding to object properties (e.g., amount, currency, status, created). Click a table name in the right panel to view its schema.
-- Common Sigma SQL example
-- Tables: charges, customers, events, disputes, refunds, subscriptions, invoices
-- Columns in 'charges': id, amount, currency, status, created, customer, payment_method
SELECT id, amount, currency, status, created
FROM charges
WHERE created > 1711324800 -- March 25, 2024 (Unix timestamp)
AND status = 'succeeded'
ORDER BY created DESC;Common Sigma Queries for Payment Analysis
Most teams use Sigma to answer recurring questions about payments, revenue, and customer behavior without writing custom integrations.
Calculate Total Revenue by Time Period
Write a GROUP BY query to sum revenue and bucket it by day or month. Filter for status = 'succeeded' to include only completed payments.
-- Sigma SQL: Daily revenue summary
SELECT
DATE(CAST(created / 1000 AS TIMESTAMP)) AS day,
currency,
COUNT(*) AS transaction_count,
SUM(amount) / 100 AS total_revenue
FROM charges
WHERE status = 'succeeded'
AND created > 1743206400 -- March 25, 2026
GROUP BY day, currency
ORDER BY day DESC;Identify Your Top Customers by Spending
Join the customers table with charges to rank customers by lifetime value. This powers segmentation, churn analysis, and customer tiers.
-- Sigma SQL: Top customers by lifetime value
SELECT
c.id AS customer_id,
c.email,
COUNT(ch.id) AS charge_count,
SUM(ch.amount) / 100 AS lifetime_value,
MAX(ch.created) AS last_charge_date
FROM customers c
LEFT JOIN charges ch ON c.id = ch.customer
WHERE ch.status = 'succeeded'
GROUP BY c.id, c.email
HAVING lifetime_value > 0
ORDER BY lifetime_value DESC
LIMIT 100;Exporting and Automating Sigma Results
Sigma queries are one-off, but you can export results as CSV and integrate recurring queries into your analytics stack.
Export Results from Sigma
After running a query, click the Download button in the results panel to export as CSV. This is useful for ad-hoc analysis or sharing with stakeholders who don't have Stripe access.
// For recurring automated exports, use the Stripe REST API
// Sigma is interactive; for scheduled reports, write a backend job
const fetchWeeklyRevenue = async () => {
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const sevenDaysAgo = Math.floor((Date.now() - 7 * 24 * 60 * 60 * 1000) / 1000);
const charges = await stripe.charges.list({
limit: 100,
created: { gte: sevenDaysAgo }
});
const total = charges.data
.filter(c => c.status === 'succeeded')
.reduce((sum, c) => sum + c.amount, 0) / 100;
console.log(`Weekly revenue: $${total}`);
return total;
};
await fetchWeeklyRevenue();Common Pitfalls
- Forgetting to convert Unix timestamps: Stripe stores time in Unix seconds, not milliseconds. Divide by 1000 when using date functions, or just compare raw timestamps in WHERE clauses.
- Querying with
status = 'pending': Most teams care about succeeded charges. Always filter explicitly to avoid confusion with failed, refunded, or uncaptured transactions. - Assuming Sigma results are real-time: Events may lag seconds to minutes before appearing in Sigma. Don't use it for live transaction alerts or time-sensitive logic.
- Not checking column names in the schema: Stripe object properties map directly to columns, but nested fields like
payment_method_detailsmay not be queryable. Verify the schema panel first before writing complex queries.
Wrapping Up
Sigma SQL is your fastest path to custom payment insights without building ETL or maintaining a data warehouse. Use it for ad-hoc revenue reports, customer segmentation, and one-off analysis. For recurring automated reporting, export results or integrate the Stripe REST API into your backend. If you want to track this automatically across tools, Product Analyst can help.