SQL Boy
TutorialsPlayground

Format & Validate

SQL FormatterSQL MinifierSyntax Validator

Convert

JSON to SQLCSV to SQLSQL to JSONRegex to SQLExcel to SQLSQL Dialect Convertersoon

Visualize

ER Diagram GeneratorSQL Schema Diff

Generate

SQL Mock Data Generator

Analyze

SQL Query ExplainerSQL Query Analyzer

Workflow hubs

FormattingConversionSchemaAnalysis
View all tools
Daily ChallengeInterviewsCheat SheetBlog

© 2026 SQL Boy. Built for developers.

ContactPrivacyTermsAI Usage PolicyEditorial StandardsAboutRSS Feed

New conversation

What can I help with?

Ask about this page, get a hint on a challenge, or explore SQL concepts.

I know what's on this page and can give answers grounded in SQL Boy content.

Current page

Friend Requests I Overall Acceptance Rate

/challenges/friend-requests-i-overall-acceptance-rate

Usage status will load after login
SQL Boy
TutorialsPlayground

Format & Validate

SQL FormatterSQL MinifierSyntax Validator

Convert

JSON to SQLCSV to SQLSQL to JSONRegex to SQLExcel to SQLSQL Dialect Convertersoon

Visualize

ER Diagram GeneratorSQL Schema Diff

Generate

SQL Mock Data Generator

Analyze

SQL Query ExplainerSQL Query Analyzer

Workflow hubs

FormattingConversionSchemaAnalysis
View all tools
Daily ChallengeInterviewsCheat SheetBlog
SQL Challenges/Friend Requests I: Overall Acceptance Rate
Challenge DetailMediumReviewed 2026-04-20

Friend Requests I: Overall Acceptance Rate

Find the overall acceptance rate of requests rounded to 2 decimals, which is the number of acceptance divided by the number of requests.

AggregationJoin

This challenge now meets the current minimum standard for sitemap inclusion and independent indexing.

2026-01-17Medium

Friend Requests I: Overall Acceptance Rate

Find the overall acceptance rate of requests rounded to 2 decimals, which is the number of acceptance divided by the number of requests.

Available Tables:
SQL Editor
Loading...

What This Challenge Is Testing

Acceptance-rate questions are common because they combine event counting, de-duplication, and ratio math in one compact problem. The same shape appears in activation funnels, confirmation rates, and conversion reporting across product analytics.

Topic Tags

AggregationAnalyticsJoins

Schema At A Glance

FriendRequest
sender_idsend_to_idrequest_date
RequestAccepted
requester_idaccepter_idaccept_date

Solution Approaches

01

Count distinct accepted pairs over distinct requests

SELECT
  ROUND(
    COUNT(DISTINCT requester_id || '-' || accepter_id) * 1.0
    / COUNT(DISTINCT sender_id || '-' || send_to_id),
    2
  ) AS accept_rate
FROM FriendRequest fr
LEFT JOIN RequestAccepted ra
  ON fr.sender_id = ra.requester_id
 AND fr.send_to_id = ra.accepter_id

This approach keeps the numerator and denominator aligned at the pair level. Distinct pairs prevent duplicate rows from inflating the request or acceptance counts.

02

Aggregate requests and acceptances separately

WITH requests AS (
  SELECT COUNT(DISTINCT sender_id || '-' || send_to_id) AS request_cnt
  FROM FriendRequest
),
accepts AS (
  SELECT COUNT(DISTINCT requester_id || '-' || accepter_id) AS accept_cnt
  FROM RequestAccepted
)
SELECT
  ROUND(accept_cnt * 1.0 / request_cnt, 2) AS accept_rate
FROM requests
CROSS JOIN accepts

Separating the counts into their own CTEs makes auditing easier. This is useful when you want to discuss numerator and denominator logic explicitly instead of mixing everything in one joined query.

Common Pitfalls

Do not use raw COUNT(*) if either table can contain duplicates. Acceptance-rate problems often include repeated request or acceptance rows, so you need to count distinct user pairs instead of physical events.

Frequently Asked Questions

Why use distinct sender-request pairs?

Because the metric is about whether a request pair exists and whether it was accepted, not how many duplicate event rows were logged for the same pair.

Should unaccepted requests still stay in the denominator?

Yes. The denominator is the set of requests sent. The numerator is the subset of those pairs that were accepted, which is why this is a conversion-style rate.

Concept Guides

Use these guides when you want the fuller explanation behind the SQL pattern this challenge is testing.

SQL Conditional Aggregation: Beyond Basic GROUP BY

Turn multiple queries into one with conditional aggregation. Learn how CASE WHEN inside aggregate functions creates powerful single-query reports and pivot tables.

Building Conversion Funnels in SQL

Master funnel analysis with SQL. Learn how to track user journeys from landing page to purchase and identify where you are losing customers.

SQL CASE Statements: Adding Logic to Your Queries

Learn how to add conditional logic to your SQL queries using CASE statements. Transform data and categorize results with ease.

Topic Hubs

If this problem exposed a deeper weakness, use a topic hub to move through a curated cluster instead of random article hopping.

Analytics

Analytics SQL and business metrics

A practical cluster for cohorts, funnels, customer value, and the kinds of reporting questions teams actually ask every week.

Advanced SQL

Advanced query patterns

Use this path when you are moving beyond beginner SELECT queries into CTEs, window functions, and conditional logic.

Practice Path

If you want the rotating practice flow, open this same question from the daily stream. If you want interview-style packaging, continue into the interview pool after this rep.

Back to ChallengesOpen In DailyBrowse Interviews

Related Challenges

Trips and UsersHard

Compute daily cancellation rate after excluding any trip where either the client or driver is banned.

Customers Who Bought All ProductsMedium

Return only the customers whose distinct purchased product set covers every product listed in the catalog.

Products Never OrderedMedium

Find products that never appear in the order table without being fooled by missing or duplicate order rows.

© 2026 SQL Boy. Built for developers.

ContactPrivacyTermsAI Usage PolicyEditorial StandardsAboutRSS Feed