Back to questions

Average Deal Size (Part 2) Salesforce SQL Interview Question

Average Deal Size (Part 2)

Salesforce SQL Interview Question

Assuming Salesforce operates on a per user (per seat) pricing model, we have a table containing contracts data.

Write a query to calculate the average annual revenue per Salesforce customer in three market segments: SMB, Mid-Market, and Enterprise. Each customer is represented by a single contract. Format the output to match the structure shown in the Example Output section below.

Assumptions:

  • Yearly seat cost refers to the cost per seat.
  • Each customer is represented by one contract.
  • The market segments are categorized as:-
    • SMB (less than 100 employees)
    • Mid-Market (100 to 999 employees)
    • Enterprise (1000 employees or more)
  • The terms "average deal size" and "average revenue" refer to the same concept which is the average annual revenue generated per customer in each market segment.

Table:

Column NameType
customer_idinteger
num_seatsinteger
yearly_seat_costinteger

Example Input:

customer_idnum_seatsyearly_seat_cost
26905025
452020050
452015050
452015050
783287850

Table:

Column NameType
customer_idinteger
namevarchar
employee_countinteger (0-100,000)

Example Input:

customer_idnameemployee_count
4520DBT Labs500
2690DataLemur99
7832GitHub878

Example Output:

smb_avg_revenuemid_avg_revenueenterprise_avg_revenue
12502500043900

Explanation:

SMB Average : DataLemur (customer ID 2690) is classified as the only SMB customer in the example data. They have a single contract with 50 seats and a yearly seat cost of $25. Therefore, the average annual revenue is: (50 * 25) / 1 = $1,250.

Mid-Market Average : DBT Labs (customer ID 4520) is the only Mid-Market customer in the example data. They have 3 contracts with a total of 500 seats and a yearly seat cost of $50. Thus, the average annual revenue is: (500 * 50) / 1 = $25,000

Enterprise Average : GitHub (customer ID 7832) is the only Enterprise customer in the example data. They have one contract with 878 seats and a yearly seat cost of $50. Therefore, the average annual revenue per Enterprise customer is: (878 * 50) / 1 = $43,900.

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

Input

Output