Quick Overview

This question evaluates proficiency in SQL data manipulation, specifically aggregation, grouping, filtering, and identification of extrema within a single-table orders dataset.

Count, Return, Find, and Select in SQL Queries

Company: OneMain Financial

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Onsite

orders +----------+--------------+------------+--------+ | order_id | customer_id | order_date | amount | +----------+--------------+------------+--------+ | 1 | 101 | 2024-01-05 | 250.00 | | 2 | 102 | 2024-01-07 | 125.50 | | 3 | 101 | 2024-01-10 | 80.00 | | 4 | 103 | 2024-01-11 | 300.00 | | 5 | 104 | 2024-01-15 | 150.00 | +----------+--------------+------------+--------+ ##### Scenario SQL screening – answer four basic queries on a single orders table ##### Question Count how many orders each customer has made. Return the total revenue generated per day. Find the customer(s) with the highest single order amount. Select all orders whose amount is above the overall average. ##### Hints GROUP BY, ORDER BY, HAVING and window functions might help.

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

For each customer, count how many orders they have placed.

Tables

orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))

Hints

  1. Group rows by customer_id.
  2. Use COUNT(*) to count orders.

Daily total revenue

Calculate the total revenue generated for each order_date.

Tables

orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))

Hints

  1. Aggregate with SUM(amount).
  2. Group by order_date.

Highest single order amount

Find the order(s) with the highest single order amount and return order_id, customer_id, and amount.

Tables

orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))

Hints

  1. Find MAX(amount) first.
  2. Filter orders where amount equals that maximum.

Orders above average amount

Select all orders whose amount is greater than the overall average order amount.

Tables

orders(order_id INTEGER, customer_id INTEGER, order_date DATE, amount DECIMAL(10,2))

Hints

  1. Compute the overall AVG(amount) in a subquery.
  2. Filter orders with amount greater than that average.
OneMain FinancialData ScientistmediumData Manipulation (SQL/Python)

Orders per customer count

For each customer, count how many orders they have placed.

Expected Output

Each customer with the number of orders they placed.

Tables

orders
orders
ColumnType
order_idINTEGER
customer_idINTEGER
order_dateDATE
amountDECIMAL(10,2)

Comments (0)

No comments yet. Be the first to comment!

Submit your answer

Approved first answer today earns 30 XP
Bold⌘BItalic⌘IInline code⌘`Bullet listTab to nest (○ ■)Numbered listTab to nest (a. i.)QuoteCode block
Formatting help
Language
Run code to see results here.

Browse More Questions