Straive FTE Hiring | Data Analyst | SQL Question | On-Campus
- Posted
- 24 Oct 2026
Summary
I completed Straive's on‑campus OA for a Data Analyst position, which consisted of an SQL query challenge and several MCQs.
How it went
I’d recently given the Straive OA for the role of Data Analyst as part of its on‑campus FTE drive for the same role, and I’d thought I’d share the question for anyone preparing for this role in the future.
Problem Description
Given two tables, Employee and Department, write a query to compute two metrics for each department:
- The exact count of employees working in that department.
- The cumulative count of employees up to and including that department, calculated as a running total over an unbounded preceding window sorted by
dep_id.
Input Tables
Department
| Column Name | Type | Description |
|---|---|---|
dep_id | INT | Primary key |
dep_name | VARCHAR | Name of the department |
Employee
| Column Name | Type | Description |
|---|---|---|
emp_id | INT | Primary key |
dep_id | INT | Foreign key referencing Department.dep_id |
emp_name | VARCHAR | Employee name |
salary | INT | Employee salary |
Approach
- Join & CTE: I started out by creating a CTE using
WITH. The CTE consisted of anINNER JOINon the Department and the Employee table on the department_id. I then grouped by department_id and selected the department_id, the department_name as well as theCOUNTof all employees inside the department (usingCOUNT(DISTINCT)to account for duplicate rows). - Window Functions: I then used the window function
SUM(employee_count) OVER (...)ordered bydep_idwithROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROWto generate the running cumulative total across departments.
Time
We were given 15 minutes for this particular problem (it should be enough if one has done LeetCode's SQL 50). The rest of the OA consisted of mostly MCQs on general aptitude, ML and Cloud Computing. It also consisted of a DSA question on arrays, which was similar to Maximum Subarray.
I hope this helps anyone prepping for this role in the future.
Questions asked (1)
- 01
Department Employee Count and Cumulative Count Query
Data Structures & Algorithms · Medium
Problem: Given two tables
EmployeeandDepartment, write a SQL query that returns for each department:- The exact number of employees in that department.
- The cumulative number of employees up to and including that department, using a running total ordered by
dep_id.
The tables are defined as follows:
Department(dep_id INT PK, dep_name VARCHAR) Employee(emp_id INT PK, dep_id INT FK, emp_name VARCHAR, salary INT)
How they prepared
I prepared by practicing LeetCode’s “SQL 50” problem set, which covered common aggregation, join, and window‑function scenarios.