Coding questions
Each question runs against a shared interview-practice database and is graded by the same 5-tier validator the mission paths use. Filter by difficulty, by pattern, or by the company the question was asked at.
Return the total number of departments at the company in a single row with a single column named `department_count`. Table: `ci_departments`.
Return the name and salary of every employee earning more than $150,000. Columns: `name`, `salary`. Order by salary descending. Table: `ci_employees`.
Return the department name and employee count for each department that has employees. Columns: `department_name`, `headcount`. Order by department name. Tables:
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Return the highest-paid employee in each department. Columns: `department_name`, `name`, `salary`. Order by department name. Tables: `ci_employees`, `ci_departm
For each month (YYYY-MM), return total monthly revenue AND the running total of revenue from the beginning of the data up through that month. Columns: `month`,
For each customer, return their most recent order. Columns: `customer_id`, `product_name`, `order_date` (as YYYY-MM-DD text), `revenue`. Order by customer_id. T
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Starting with Mia Jackson, return her reporting chain all the way up to the person with no manager. Columns: `depth`, `name`. depth=0 is Mia herself, depth=1 is
For each customer, find the longest gap (in days) between any two consecutive orders. Columns: `customer_id`, `longest_gap_days`. Order by longest_gap_days desc
For each month (YYYY-MM), return total monthly revenue AND a 3-month trailing average (current month plus the 2 prior; at the left edge the average just uses wh
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Define a customer 'session' as a run of orders where no two consecutive orders are more than 30 days apart. The first order starts a session; each gap > 30 days
For each department that has employees, return the median salary. Columns: `department_name`, `median_salary`. Order by department name. Tables: `ci_employees`,
Rank customers by total lifetime spend and bucket them into 4 equal-sized quartiles (quartile 1 = highest spenders). Columns: `customer_id`, `total_spend`, `spe
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.
Unlock with Pro to see this question.