PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/Apple

Write queries to compute salary and budget stats

Last updated: Mar 29, 2026

Quick Overview

This set of tasks evaluates data manipulation and analytical competencies, specifically the ability to compute order-statistics on numeric columns, perform relational joins to enrich event records, and reason about constrained selection for maximizing hires using SQL and pandas.

  • easy
  • Apple
  • Data Manipulation (SQL/Python)
  • Data Scientist

Write queries to compute salary and budget stats

Company: Apple

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Onsite

You are given the following interview tasks. Write solutions in **SQL and/or Python (pandas)** as appropriate. ## Task 1 — Second highest salary You have a table: **employees** - `employee_id` INT (PK) - `name` VARCHAR - `salary` INT Return the **second highest distinct salary**. - If there is **no** second distinct salary, return `NULL`. **Required output** - `second_highest_salary` (INT or NULL) ## Task 2 — Merge two datasets You are given two datasets that share a common key: **users** - `user_id` INT (PK) - `country` VARCHAR - `signup_date` DATE **user_events** - `user_id` INT (FK → users.user_id) - `event_time` TIMESTAMP - `event_type` VARCHAR Merge them so that each event row is enriched with user attributes. - Keep only events that have a matching `user_id` in `users` (inner join). **Required output** - `user_id`, `country`, `signup_date`, `event_time`, `event_type` ## Task 3 — “Run out the budget” (maximize hires) You have a list/table of employees with their salaries and a total hiring budget `B`. - Each employee costs exactly their `salary`. - You can hire at most once per employee. - Goal: **maximize the number of employees hired** without exceeding the budget. **Input** - `employees(employee_id, salary)` and an integer `B` **Required output** - `max_hires` (INT) Clarify any assumptions you need (e.g., what to do if `B <= 0`).

Quick Answer: This set of tasks evaluates data manipulation and analytical competencies, specifically the ability to compute order-statistics on numeric columns, perform relational joins to enrich event records, and reason about constrained selection for maximizing hires using SQL and pandas.

Related Interview Questions

  • Detect sessions and gaps using SQL LEAD - Apple (Medium)
  • Analyze TSV File for User Page Visits and Patterns - Apple (Medium)
  • Compute and Rank Store Revenue by Region Using Pandas - Apple (Medium)
  • Explain Python lists, dicts, and concurrency - Apple (Medium)
Apple logo
Apple
Aug 24, 2025, 12:00 AM
Data Scientist
Onsite
Data Manipulation (SQL/Python)
4
0

You are given the following interview tasks. Write solutions in SQL and/or Python (pandas) as appropriate.

Task 1 — Second highest salary

You have a table:

employees

  • employee_id INT (PK)
  • name VARCHAR
  • salary INT

Return the second highest distinct salary.

  • If there is no second distinct salary, return NULL .

Required output

  • second_highest_salary (INT or NULL)

Task 2 — Merge two datasets

You are given two datasets that share a common key:

users

  • user_id INT (PK)
  • country VARCHAR
  • signup_date DATE

user_events

  • user_id INT (FK → users.user_id)
  • event_time TIMESTAMP
  • event_type VARCHAR

Merge them so that each event row is enriched with user attributes.

  • Keep only events that have a matching user_id in users (inner join).

Required output

  • user_id , country , signup_date , event_time , event_type

Task 3 — “Run out the budget” (maximize hires)

You have a list/table of employees with their salaries and a total hiring budget B.

  • Each employee costs exactly their salary .
  • You can hire at most once per employee.
  • Goal: maximize the number of employees hired without exceeding the budget.

Input

  • employees(employee_id, salary) and an integer B

Required output

  • max_hires (INT)

Clarify any assumptions you need (e.g., what to do if B <= 0).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Apple•More Data Scientist•Apple Data Scientist•Apple Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
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.