SQL Playground
TutorialsPlayground
SQL FormatterSQL MinifierSyntax ValidatorJSON to SQLCSV to SQLSQL to JSONER Diagram Generator
Daily ChallengeInterviewsCheat SheetBlog

© 2026 SQL Playground. Built for developers.

PrivacyTermsAboutRSS Feed
SQL Playground
TutorialsPlayground
SQL FormatterSQL MinifierSyntax ValidatorJSON to SQLCSV to SQLSQL to JSONER Diagram Generator
Daily ChallengeInterviewsCheat SheetBlog
Back to Pool
Stripe

Payment Success Rate by Country

Calculate the payment success rate for each country. Success rate is the number of successful payments divided by total payment attempts. Round to 2 decimal places and only show countries with at least 5 payment attempts.

Schema

SQL Editor
Loading...

Execution Result

Write and run your query to see results here.

Problem Context & Learning

💡Why This Question Matters

This metrics calculation problem reflects Stripe's core business of payment processing analytics. Understanding success rates by geography is critical for identifying fraud patterns, optimizing routing, and improving authorization rates. This question tests your ability to perform conditional aggregation, calculate percentages correctly, and apply filtering at the right stage of query execution.

🔑Key SQL Concepts

Key concepts: CASE WHEN for conditional counting, GROUP BY for country-level aggregation, HAVING clause for post-aggregation filtering, ROUND() for precision, and division with proper type casting (1.0 for float division). Understanding the difference between WHERE (pre-aggregation) and HAVING (post-aggregation) is crucial.

🌍Real-World Applications

Stripe's analytics teams use similar queries to: generate country-specific success rate dashboards for merchants, identify regions requiring payment method optimization, calculate SLA compliance metrics, detect anomalies in authorization patterns, feed machine learning models for fraud detection, and power automated alerts when success rates drop below thresholds.

Interview Insights & Approach

Strategic Approach

When tackling this Stripe problem, the key is to understand the grain of the result. Are you returning one row per user, or one row per category? Always start by identifying your unique join keys and consider if filtered aggregations (CASE WHEN) are more efficient than multiple subqueries.

Common Pitfalls

Be careful with NULL values in your JOIN conditions or aggregate functions. In interview scenarios, datasets often include edge cases like zero-count categories or duplicate entries that can throw off a simple COUNT(*) if not handled with DISTINCT.

Discussion & Solutions

Share your approach, optimized queries, or ask questions. Learning from others is the fastest way to master SQL.

💬 Join the conversation below

Comments

© 2026 SQL Playground. Built for developers.

PrivacyTermsAboutRSS Feed