Google-style Company ChallengeMediumVerified answerSQLite live

Daily Ad Revenue Trend

What is the total ad revenue and click count for each day?

  • Aggregation
  • Date analysis
  • Numeric functions
  • Sorting

Challenge brief

Understand the request

Ads Finance is building a daily revenue dashboard and needs total click revenue per day to monitor ad performance trends.

Return click_date, daily_revenue, click_count in the declared deterministic order.

Return

  • click_date
  • daily_revenue (rounded 2)
  • click_count

Constraints

  • Return one row per click date
  • Round revenue to two decimals
  • Order chronologically

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

ad_clicks

  • click_dateDATE
  • revenueREAL

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Each click contributes revenue to one click date.

Hint 2

Aggregate count and revenue at daily grain.

Hint 3

Round revenue and return the series chronologically.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT click_date, ROUND(SUM(revenue), 2) AS daily_revenue, COUNT(*) AS click_count FROM ad_clicks GROUP BY click_date ORDER BY click_date

Why this works

Single-table GROUP BY. Jan 24 has the highest daily revenue ($11.70) from 3 clicks. ROUND(SUM(revenue), 2) prevents floating-point display issues.

Success check

Returns the complete deterministic result for daily ad revenue trend

Expected result

Use this output to verify values, aliases, ordering, and row count.

click_datedaily_revenueclick_count
2024-01-106.252
2024-01-111.251
2024-01-127.52
2024-01-134.21
2024-01-146.552
2024-01-155.42
2024-01-169.52
2024-01-173.21
2024-01-187.653
2024-01-196.82

Previewing 10 of 16 expected rows. Run the query in the editor to inspect the full result.

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Interview Practice

Return to the complete interview preparation experience.