PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency in data manipulation and time-series sequence analysis, specifically measuring the longest run of consecutive successful transactions per user from transactional logs.

  • Medium
  • Capital One
  • Data Manipulation (SQL/Python)
  • Data Scientist

Calculate Longest Transaction Streak for Each User

Company: Capital One

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

transactions +---------------+---------+--------+----------------+-----------+----------+ | transaction_id| user_id | amount | transaction_date| merchant | status | +---------------+---------+--------+----------------+-----------+----------+ | 1001 | 11 | 23.50 | 2023-05-01 | Amazon | success | | 1002 | 11 | 9.99 | 2023-05-02 | Spotify | success | | 1003 | 11 | 42.10 | 2023-05-04 | Walmart | success | | 2001 | 20 | 19.99 | 2023-05-02 | Netflix | failed | | 2002 | 20 | 15.75 | 2023-05-03 | Target | success | +---------------+---------+--------+----------------+-----------+----------+ ##### Scenario OA round: SQL challenge on customer transactions data; task is to derive meaningful user-level insights. ##### Question For each user, calculate the longest streak (in days) of consecutive successful transactions and output user_id with longest_streak ordered desc; ignore failed or reversed transactions. ##### Hints Gap-and-islands or window functions (LAG, DATE_DIFF) can identify consecutive-day groups.

Quick Answer: This question evaluates proficiency in data manipulation and time-series sequence analysis, specifically measuring the longest run of consecutive successful transactions per user from transactional logs.

Last updated: Mar 29, 2026

Loading coding console...

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.

Related Coding Questions

  • Clean and Merge Housing Data - Capital One (easy)
  • Find Lowest Prices for Highly Rated Categories - Capital One (medium)
  • Write SQL to compute campaign net revenue - Capital One (Medium)
  • Merge CSVs and build revenue pivot with pandas - Capital One (Medium)
  • Find top category per region in Aug 2025 - Capital One (Medium)