PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates data manipulation and aggregation skills in Python (pandas) and SQL by testing transactional filtering, handling of refunds, and computation of per-user total spending.

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

Compute Total Spent in 2023 Excluding Refunds

Company: Visa

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

transactions +----------------+---------+-------------+--------+------------------+ | transaction_id | user_id | merchant_id | amount | transaction_date | +----------------+---------+-------------+--------+------------------+ | 1 | 101 | 2001 | 120 | 2023-01-10 | | 2 | 102 | 2002 | -20 | 2023-02-14 | | 3 | 101 | 2001 | 30 | 2022-12-31 | | 4 | 103 | 2003 | 55 | 2023-03-05 | | 5 | 101 | 2002 | 75 | 2023-04-17 | +----------------+---------+-------------+--------+------------------+ ##### Scenario Visa analytics role – technical round requiring the same data-manipulation task solved first in Python and then in SQL. ##### Question Using Python (pandas), compute each user’s total amount spent in 2023, excluding refunds (negative amounts). Return user_id and total_spent sorted by total_spent descending. Rewrite the same solution in SQL, using a CTE and GROUP BY. ##### Hints Filter dates, ignore negative amounts, aggregate, sort.

Quick Answer: This question evaluates data manipulation and aggregation skills in Python (pandas) and SQL by testing transactional filtering, handling of refunds, and computation of per-user total spending.

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.