Skip to content

3055. Top Percentile Fraud

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
WITH
  FraudPercentile AS (
    SELECT
      policy_id,
      state,
      fraud_score,
      PERCENT_RANK() OVER(
        PARTITION BY state
        ORDER BY fraud_score DESC
      ) AS `percent_rank`
    FROM Fraud
  )
SELECT policy_id, state, fraud_score
FROM FraudPercentile
WHERE `percent_rank` < 0.05
ORDER BY state, fraud_score DESC, policy_id;