KatInterview

Measuring a Premium Plan Launch and Building Fraud Alert Rules

SQL & DataModel answer
HardModel answerSQL & Dataproduct-analyticscohort-retentionsql-window-functions

Last updated

Define launch success for a new paid tier using only transaction and activity tables, then design a rule-based SQL alerting system for suspicious payments.

You work on the analytics team of a consumer finance app. All timestamps are UTC. These tables are available:

  • users(user_id BIGINT PK, create_date TIMESTAMP, country VARCHAR): signup time and registration country.
  • transactions(transaction_id BIGINT PK, user_id BIGINT, product VARCHAR, amount_gbp DECIMAL(12,2), status VARCHAR, transaction_time TIMESTAMP): one row per transaction.
  • activity(user_id BIGINT, product VARCHAR, event_type VARCHAR, event_time TIMESTAMP, ip_country VARCHAR): one row per product interaction, with the IP country observed at that event.

Answer both scenarios.

Scenario 1: Launch of a new top-tier paid plan

The company has just released a paid plan whose rows carry product = 'ultra'. There is no subscriptions table, so adoption must be inferred from the tables above. Define what a successful first month looks like and describe the SQL analyses you would build. Cover:

  • one primary success metric and several supporting metrics,
  • denominator choices (all users, active users, new users) and their trade-offs,
  • segmentation by country and by account tenure,
  • how to compute DAU/WAU/MAU, adoption, penetration, and early retention,
  • how to avoid misleading conclusions from seasonality, country-mix shifts, and self-selection.

Scenario 2: Rule-based suspicious activity detection

Together with the financial-crime team, design a rule-based SQL system that flags users or transactions for manual review. Turn "suspicious" into executable rules that use only the tables above. Consider:

  • unusually large amounts,
  • bursts of transactions in a short window,
  • repeated small probing payments,
  • a sudden jump in the number of products used,
  • registration country differing from the recent IP country.

Define the alert table you would output, example rules with thresholds, how rules combine into a score or review queue, and how you would measure precision, recall, and false positives.

Hints

Hint 1

Start by writing down your proxy for a subscriber (for example, a completed fee transaction with no later refund) and for an engaged user (an activity row). Every later metric builds on those two definitions.

Hint 2

For penetration, restrict both numerator and denominator to eligible countries and to users who were active before launch. For retention, build cohorts by the week of first payment and check activity in weeks 1 to 4.

Hint 3

For fraud rules, use time-ranged window functions for bursts, ROW_NUMBER for the latest IP, and store one row per rule hit so scores can be recomputed and each rule evaluated separately. Plan for recall measurement by sampling alerts below the threshold.

Hint 4

For causal claims, think of holdouts, staggered rollout, difference-in-differences against non-launch markets, and matching on pre-period behavior.