straive logo
Straive· Data Analyst

Straive FTE Hiring | Data Analyst | SQL Question | On-Campus

Posted
24 Oct 2026
1 reads

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:

  1. The exact count of employees working in that department.
  2. 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 NameTypeDescription
dep_idINTPrimary key
dep_nameVARCHARName of the department

Employee

Column NameTypeDescription
emp_idINTPrimary key
dep_idINTForeign key referencing Department.dep_id
emp_nameVARCHAREmployee name
salaryINTEmployee salary

Approach

  1. Join & CTE: I started out by creating a CTE using WITH. The CTE consisted of an INNER JOIN on 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 the COUNT of all employees inside the department (using COUNT(DISTINCT) to account for duplicate rows).
  2. Window Functions: I then used the window function SUM(employee_count) OVER (...) ordered by dep_id with ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW to 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)

  1. 01

    Department Employee Count and Cumulative Count Query

    Data Structures & Algorithms · Medium

    Problem: Given two tables Employee and Department, write a SQL query that returns for each department:

    1. The exact number of employees in that department.
    2. 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.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Straive recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!