logo

Back to questions

Ad Campaign ROAS

Easy

Google marketing managers are analyzing the performance of various advertising accounts over the last month. They need your help to gather the relevant data.

Write a query to calculate the return on ad spend (ROAS) for each advertiser across all ad campaigns. Round your answer to 2 decimal places, and order your output by the .

Hint: ROAS = Ad Revenue / Ad Spend

Table:

Column NameType
campaign_idinteger
spendinteger
revenuefloat
advertiser_idinteger

Example Input:

campaign_idspendrevenueadvertiser_id
1500075003
210009001
33000120002
450020004
51004004

Example Output:

advertiser_idROAS
10.9
24
31.5
44

Explanation

The example output shows that 1 returned 90% of their ad spend, 2 returned 400% of their ad spend, and so on.

PostgreSQL 14

Refer friends to get bonus content & cool prizes.