Back to questions
Assume that Salesforce customers pay on a per user basis (also referred to as per seat model). Given a table of contracts data, write a query to calculate the average annual revenue per Salesforce customer. Round your answer to 2 decimal places.
Assume each customer only has 1 contract and the yearly seat cost refers to cost per seat.
The dataset you are querying against may have different input & output - this is just an example!
The following formula can be used to calculate the average annual revenue per Salesforce customer.
Average deal size = (Number of seats x Yearly seat cost) / (Number of contracts)
table doesn't have any column specific to the contract. As mentioned in the question, the assumption is one customer will have only one contract. Hence, it means that the number of contracts = number of customers present in the table.
How to convert the formula into SQL codes
Aggregate function allows you to get the number of rows and returns the sum of the values.
Average deal size in SQL will look like this:
 function rounds a numeric value to its nearest integer or a number with the number of decimal places.
Now, we combine everything we have learnt to construct a SQL query.