Measure Weekly Seat Utilization per Law Firm

Last updated: November 29, 2026

Quick Overview

Given a seats table (user, firm, licence status) and a usage events table, write SQL that returns, for a given week, each firm's licensed seats, active seats (licensed users with at least one event) and utilization ratio, lowest utilization first.

Legora
Data Manipulation (SQL/Python)
Data Scientist
Legora
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Given a seats table (user, firm, licence status) and a usage events table, write SQL that returns, for a given week, each firm's licensed seats, active seats (licensed users with at least one event) and utilization ratio, lowest utilization first.

Legora sells seat licences to law firms, and customer success teams watch which firms have bought seats that lawyers are not using. A quick SQL screen like this checks join choice, distinct counting and the definition of 'active' before any modelling work.

What the Interviewer Expects
  • Asks what counts as active and which events qualify
  • Restricts the denominator to currently licensed seats
  • Uses a LEFT JOIN so firms with zero activity still appear
  • Counts distinct active users, not events
  • Uses a half-open date range for the week
  • Ignores events from users without a seat
Key Topics to Cover
LEFT JOIN
COUNT DISTINCT
date ranges
SaaS seat metrics
grouping
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you show the trend over the last 12 weeks per firm in one query?
  • How would you handle a seat that was licensed only for part of the week?
  • Which features should count as real usage rather than just opening the app?
  • How would you flag firms whose utilization dropped by more than 20 points?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

seats(user_id, firm_id, status) with status active or revoked; usage_events(user_id, occurred_at, feature). I confirm: active = at least one event of any feature in the week; denominator = sea...

Approach

Build the set of distinct users who had an event in the window, then LEFT JOIN licensed seats to it. COUNT(*) counts seats and COUNT(a.user_id) counts only matched (active) seats, since unmatched ...


Submit Your Answer
Markdown supported

Related Questions