Rank Projects by Billable Utilization Within Each Business Unit
Last updated: November 29, 2026
Quick Overview
Given timesheets (associate_id, project_id, week_start, hours, is_billable) and projects (project_id, business_unit), write SQL that computes each project's billable utilization for October 2026 and ranks projects within their business unit from highest to lowest.
Cognizant
November 29, 20260
0
0 solved
Given timesheets (associate_id, project_id, week_start, hours, is_billable) and projects (project_id, business_unit), write SQL that computes each project's billable utilization for October 2026 and ranks projects within their business unit from highest to lowest.
Billable utilization is the key operating metric for an IT services firm like Cognizant, reported by business units such as BFSI and Healthcare. This warm-up checks conditional aggregation, safe division, and choosing the right ranking function.
What the Interviewer Expects
- Joins timesheets to projects to get the business unit
- Uses conditional SUM for billable hours
- Guards division with NULLIF
- Partitions the rank by business unit
- Chooses DENSE_RANK or RANK deliberately and explains ties
- Filters on the month with a half-open date range
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you compute utilization per associate instead, with a denominator of 40 available hours per week?
- How do you handle a week that starts in September but ends in October?
- Show only the bottom two projects per business unit.
- How would you build this as a dashboard metric that refreshes daily?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Utilization here is billable hours divided by total logged hours on the project, as a percentage. is_billable is 0 or 1. October means weeks whose week_start falls in October; I will confirm wheth...
Approach
Aggregate per project first in a CTE: billable hours via SUM(CASE WHEN is_billable = 1 THEN hours ELSE 0 END) and total hours via SUM(hours). Then apply DENSE_RANK() partitioned by business unit...