EasyFundamentals
High-Value Active SaaS Subscriptions
Frequently Asked By:MicrosoftGoogleStripe
Interactive In-Browser Workspace
Practice this problem on live schema tables in PostgreSQL 16 WASM with instant row verification and visual EXPLAIN plans.
Problem Statement
Write a query to retrieve all active enterprise subscriptions paying at least **$1,500** in MRR.
Return the following columns:
1. `subscription_id`
2. `company_name`
3. `plan_tier`
4. `monthly_amount` (renamed as `mrr`)
Order the results by `monthly_amount` in **descending** order. If two subscriptions have the same MRR, break ties by `company_name` ascending.
Why Technical Interviewers Ask This
You are the lead product data analyst at CloudScale, an enterprise cloud observability platform. The sales team wants an urgent list of enterprise customers currently on active plans paying an Monthly Recurring Revenue (MRR) of $1,500 or more, so they can offer an annual contract upgrade.
Common Pitfalls & Interview Traps
Forgetting required sorting and deterministic tie-breaking.
Not accounting for NULL or zero-value denominators during calculations.
Using inefficient quadratic subqueries instead of single-pass fundamentals constructs.
Canonical Modern SQL Solution
PostgreSQL 16 / ANSI SQLSELECT
subscription_id,
company_name,
plan_tier,
monthly_amount AS mrr
FROM subscriptions
WHERE status = 'active' AND monthly_amount >= 1500.00
ORDER BY monthly_amount DESC, company_name ASC;Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Fundamentals. It meets the target criteria: A table with subscription_id, company_name, plan_tier, and mrr sorted by highest MRR first.Edge Cases to Verbally Clarify with Your Interviewer
The dataset contains zero matching records (must return valid empty result without crashing).
Multiple records tie on sorting criteria (must evaluate tie-breaking order deterministically).
Foreign keys or secondary attributes have NULL values.
Frequently Asked Follow-Up Questions
What makes this question a favorite among Microsoft and Google interviewers?
Interviewers use this problem to test whether candidates write defensive, scalable Fundamentals queries that run efficiently on multi-million row production databases without excessive memory usage.
How does the query optimizer execute this query?
Using single-pass table scans with index lookups or sort buffers. Running EXPLAIN (ANALYZE, BUFFERS) in the DB Exercises workbench visualizes the execution nodes and buffer hit cache.