Clicked Ad Impressions

An easy SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.

Domain
SQL
Difficulty
easy
Seniority
L3
Asked in
Meta

Problem

The ad analytics team needs the raw data behind every clicked impression for a detailed review. Pull all fields from ad impression records where the user clicked.

They saw the ad. They clicked.

Tables

ad_impressions

Columns: impression_id INTEGER, user_id INTEGER, ad_campaign TEXT, impression_time TEXT, clicked INTEGER, revenue REAL

ad_impressions: 10 of 200 rows
impression_iduser_idad_campaignimpression_timeclickedrevenue
253100BRAND_AWARENESS_Q12026-02-02 01:07:000NULL
306197PRODUCT_LAUNCH_X2026-03-03 02:14:000NULL
359294RETARGETING_CART2026-04-04 03:21:000NULL
412391HOLIDAY_PROMO2026-05-05 04:28:000NULL
465488NEW_USER_ACQU2026-06-06 05:35:0010.2
518NULLLOYALTY_PROGRAM2026-07-07 06:42:000NULL
571682FLASH_SALE_48H2026-08-08 07:49:000NULL
624779SUMMER_SALE_20242026-09-09 08:56:000NULL
677876BRAND_AWARENESS_Q12026-01-10 09:03:000NULL
730973PRODUCT_LAUNCH_X2026-02-11 10:10:0010.35

Expected output

First 5 of 99 rows
impression_iduser_idad_campaignimpression_timeclickedrevenue
465488NEW_USER_ACQU2026-06-06 05:35:0010.2
730973PRODUCT_LAUNCH_X2026-02-11 10:10:0010.35
995488FLASH_SALE_48H2026-07-16 15:45:0010.5
1260973HOLIDAY_PROMO2026-03-21 20:20:0010.65
1525488BRAND_AWARENESS_Q12026-08-26 01:55:0010.8

Worked solution and explanation

Why this problem exists in real interviews

This is the simplest possible filter query. It screens for the baseline ability to write a WHERE clause and use SELECT * correctly.


Break down the requirements

Step 1: Filter to clicked impressions

WHERE clicked = 1 restricts to rows where the user clicked.

Step 2: Return all fields

SELECT * returns every column as requested.


The solution

Simple equality filter
SELECT *
FROM ad_impressions
WHERE clicked = 1

Common follow-up questions