SQL · Intermediate · 35 min

Top visitors with tied activity counts

Rank distinct-page counts while preserving ties.

Task

For 2026-01-15, return visitors in the top two distinct-page-count ranks. If several visitors tie, include them all. Repeated impressions of one page count once.

Requirements

  • impressions has visitor_id, page_name, and day.
  • Return visitor_id and distinct_pages. Rank by distinct page count descending.
  • Use dense ranks: counts of 5, 5, and 3 occupy ranks 1, 1, and 2.
  • Order by distinct_pages descending, then visitor_id ascending. Use SQLite.
DENSE_RANKDistinct countsTies

Loading exercise…