Ad Click Filtering

ASKED IN INTERVIEW
2pts
Google

Problem Statement

Google Ads team wants to refine their billing by identifying "low-quality" clicks. A low-quality click is defined as an instance where a user clicked an ad but spent 5 seconds or less on the destination landing page.

Write an SQL query to find all ad_ids where a click occurred but the stay duration was 5 seconds or less.

Rules:

  • Only consider records where clicked is TRUE.
  • The stay_duration_seconds must be less than or equal to 5.
  • Output columns: ad_id, stay_duration_seconds.
  • Sort the results by stay_duration_seconds in ascending order.

Table Schema:

  • AdClicks: click_id, ad_id, user_id, clicked (BOOLEAN), stay_duration_seconds (INTEGER).
Tests your understanding of
Basic SQL, Filtering and Logical Operators

Input Tables

AdClicks
ad_id(INTEGER)clicked(BOOLEAN)stay_duration_seconds(INTEGER)
101true2
102true15
103false0
104true5
105true1
106true6

Expected Output

ad_id(INTEGER)stay_duration_seconds(INTEGER)
1051
1012
1045

Tags

EasyASKED IN INTERVIEWBasic SQLFilteringLogical Operators
5-10 min
78%

Hints