Count, Return, Find, and Select in SQL Queries
Company: OneMain Financial
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Onsite
Overview: This question evaluates proficiency in SQL data manipulation, specifically aggregation, grouping, filtering, and identification of extrema within a single-table orders dataset.
Orders per customer count
Tables
orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))
Hints
- Group rows by customer_id.
- Use COUNT(*) to count orders.
Daily total revenue
Tables
orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))
Hints
- Aggregate with SUM(amount).
- Group by order_date.
Highest single order amount
Tables
orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))
Hints
- Find MAX(amount) first.
- Filter orders where amount equals that maximum.
Orders above average amount
Tables
orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))
Hints
- Compute the overall AVG(amount) in a subquery.
- Filter orders with amount greater than that average.