Fraud Rate Cutoff

Start Timer

0:00:00

Upvote
7
Downvote
Save question
View comments

Let’s say at Socure we have an applications table where each row is a submitted application with its client, when its fraud outcome was resolved, and whether it was fraudulent. Write a query that returns each client’s fraud rate, using only outcomes resolved by the cutoff date 2026-03-01.

Rules - Fraud rate is the number of fraudulent applications resolved by the cutoff divided by the total number of applications resolved by the cutoff. - The cutoff covers the entire day of 2026-03-01, so any resolved_at up to and including 2026-03-01 23:59:59 is included. - Applications resolved after the cutoff, or still unresolved, are excluded from both the numerator and the denominator. - Exclude clients that have no outcomes resolved by the cutoff. - Round fraud_rate to 4 decimal places and order rows by client_id ascending.

Example:

Input:

applications table

Column Type
id INTEGER
client_id INTEGER
resolved_at DATETIME
is_fraud BOOLEAN

Output:

Column Type
client_id INTEGER
fraud_rate FLOAT
.
.
.
.
.


Comments

Loading comments