Back to questions

Consulting Bench Time Google SQL Interview Question

Consulting Bench Time

Google SQL Interview Question

In consulting, being "on the bench" means you have a gap between two client engagements. Google wants to know how many days of bench time each consultant had in 2021. Assume that each consultant is only staffed to one consulting engagement at a time.

Write a query to pull each employee ID and their total bench time in days during 2021.

Assumptions:

  • All listed employees are current employees who were hired before 2021.
  • The engagements in the table are complete for the year 2022.

Table:

Column NameType
employee_idinteger
is_consultantboolean
job_idinteger

Example Input:

employee_idis_consultantjob_id
111true7898
121false6789
156true4455

Table:

Column NameType
job_idinteger
client_idinteger
start_datedate
end_datedate
contract_amountinteger

Example Input:

job_idclient_idstart_dateend_datecontract_amount
78982007605/25/2021 00:00:0006/30/2021 00:00:0011290.00
67892004506/01/2021 00:00:0011/12/2021 00:00:0033040.00
44552000101/25/2021 00:00:0005/31/2021 00:00:0031839.00

Example Output:

employee_idbench_days
111328
156238

Explanation

Employee 111 had 328 days of bench time in 2021.

To calculate the 328 days of bench time for employee id 111, we first calculate their total number of work days between start date 05/25/2021 and end date 06/30/2021. Then we subtract this work time from 365 (days in a year) to get the number of bench days: 328.

The dataset you are querying against may have different input & output - this is just an example!

Input

Output