PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/Coinbase

Write SQL: sum values ≤ each row’s value

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in SQL aggregation, query optimization, and handling duplicate values when computing cumulative sums across rows. It is commonly asked to assess practical ability in the Data Manipulation (SQL/Python) domain to design scalable, efficient queries and demonstrates a focus on practical application of query-design and optimization rather than purely conceptual theory.

  • Medium
  • Coinbase
  • Data Manipulation (SQL/Python)
  • Data Scientist

Write SQL: sum values ≤ each row’s value

Company: Coinbase

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

Given table numbers(id INT PRIMARY KEY, val INT), return for every row the sum of all val across the entire table that are ≤ that row’s val (i.e., compare against values, not row order). Aim for an approach that avoids O(n²) correlated subqueries on large tables. Sample data: numbers id | val 1 | 1 2 | 2 3 | 15 4 | 14 5 | 13 6 | 2 7 | 1 Requirements: - Output columns: id, val, sum_leq. - Ties count fully (e.g., for val=2, include all rows with val 1 or 2). - Provide an ANSI-SQL solution that scales (hint: pre-aggregate by val, then use a cumulative sum over distinct val and join back).

Quick Answer: This question evaluates proficiency in SQL aggregation, query optimization, and handling duplicate values when computing cumulative sums across rows. It is commonly asked to assess practical ability in the Data Manipulation (SQL/Python) domain to design scalable, efficient queries and demonstrates a focus on practical application of query-design and optimization rather than purely conceptual theory.

Related Interview Questions

  • Compute adoption, latency, and cross-region transactions - Coinbase (Medium)
  • Write SQL and Python for funnels/retention - Coinbase (Medium)
  • Implement filters and cursor pagination - Coinbase (Medium)
  • Compute delivery metrics and top-K queries - Coinbase (Medium)
  • Calculate Cumulative Sum for Each Integer in Table - Coinbase (Medium)
Coinbase logo
Coinbase
Oct 13, 2025, 9:49 PM
Data Scientist
Onsite
Data Manipulation (SQL/Python)
4
0

Given table numbers(id INT PRIMARY KEY, val INT), return for every row the sum of all val across the entire table that are ≤ that row’s val (i.e., compare against values, not row order). Aim for an approach that avoids O(n²) correlated subqueries on large tables. Sample data: numbers id | val 1 | 1 2 | 2 3 | 15 4 | 14 5 | 13 6 | 2 7 | 1 Requirements:

  • Output columns: id, val, sum_leq.
  • Ties count fully (e.g., for val=2, include all rows with val 1 or 2).
  • Provide an ANSI-SQL solution that scales (hint: pre-aggregate by val, then use a cumulative sum over distinct val and join back).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Coinbase•More Data Scientist•Coinbase Data Scientist•Coinbase Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.