Member-only story

Ad Campaign ROAS — SQL Questions Asked By Google

Solving Questions Asked By Google

Suraj Mishra
2 min readSep 24, 2022

Originally Published in https://asyncq.com/

Photo by Caspar Camille Rubin on Unsplash

Introduction

  • In this article we will solve Ad Campaign ROAS SQL question which is asked by Google as per DataLemur website.

If you don’t know DatLemur then please do visit , it’s one of the best website to practice SQL questions and improve your SQL skills.

Question

  • We have been given ad_campaigns table and we have to analyze performance of various advertisement account.
  • We need to calculate return on ad spend (ROAS) for each advertiser.

Solution

  • At first we need to understand what is ROAS. its basically ad revenue / ad spend.
  • In order to calculate ROAS ratio we need to group by our input table with advertiser_id , once we group then we can sum all the ad_spend and ad_revenue.
  • Once we have total_ad_spend and total_ad_revenue we can get ROAS by dividing them.
  • We will round ROAS to 2 decimal places because it was asked in Question.
  • Once we run above query we get the desired result.

--

--

Suraj Mishra
Suraj Mishra

Written by Suraj Mishra

Staff Software Engineer @PayPal ( All opinions are my own and not of my employer )

No responses yet