PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Salesforce

Write SQL for top spender and non-spenders

Last updated: Mar 29, 2026

Quick Overview

This question evaluates SQL querying skills including aggregation and grouping, date/time windowing for previous-calendar-month calculations, joins and handling absence of rows to identify top spenders and users with no transactions.

  • medium
  • Salesforce
  • Software Engineering Fundamentals
  • Software Engineer

Write SQL for top spender and non-spenders

Company: Salesforce

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

## SQL Questions Assume the following schema: - `users(user_id, created_at, ...)` - `transactions(txn_id, user_id, amount, txn_ts)` - `amount` is a positive number for a successful purchase. ### Q1: Biggest spender last month Write a SQL query to find the **user(s)** with the **largest total spend in the previous calendar month**. ### Q2: Users who never spent Write a SQL query to find **users who have never made a purchase** (no rows in `transactions`). > If you need additional assumptions (timezone, refunds, ties), state them explicitly.

Quick Answer: This question evaluates SQL querying skills including aggregation and grouping, date/time windowing for previous-calendar-month calculations, joins and handling absence of rows to identify top spenders and users with no transactions.

Related Interview Questions

  • Choose DynamoDB vs MySQL for a backend - Salesforce (medium)
  • How do you perform a thorough code review? - Salesforce (hard)
  • Design an Elevator Control System - Salesforce (easy)
Salesforce logo
Salesforce
Jan 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Software Engineering Fundamentals
6
0
Loading...

SQL Questions

Assume the following schema:

  • users(user_id, created_at, ...)
  • transactions(txn_id, user_id, amount, txn_ts)
    • amount is a positive number for a successful purchase.

Q1: Biggest spender last month

Write a SQL query to find the user(s) with the largest total spend in the previous calendar month.

Q2: Users who never spent

Write a SQL query to find users who have never made a purchase (no rows in transactions).

If you need additional assumptions (timezone, refunds, ties), state them explicitly.

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Salesforce•More Software Engineer•Salesforce Software Engineer•Salesforce Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 8,000+ 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.