This question evaluates proficiency in SQL data manipulation and analytical metrics computation, including deduplication, session-level filtering, time-window aggregations, and click-through rate calculations within the Data Manipulation (SQL/Python) domain.

Assume today is 2025-09-01. Compute the top 3 shops by average daily visibility share over the last 7 days (2025-08-26 to 2025-09-01, inclusive) for US, non-bot traffic.
Definitions
Schema (standard SQL) users(user_id INT PRIMARY KEY, country STRING) shops(shop_id INT PRIMARY KEY, shop_name STRING, category STRING) searches(search_id INT PRIMARY KEY, user_id INT, session_id STRING, search_ts TIMESTAMP, query STRING, is_bot BOOLEAN) search_results(search_id INT, position INT, shop_id INT, clicked BOOLEAN)
Sample data (minimal) users | user_id | country | | 1 | US | | 2 | US | | 3 | CA |
shops | shop_id | shop_name | category | | 101 | Alpha Apparel | Clothing | | 102 | Beta Bikes | Sports | | 103 | Gamma Gadgets | Electronics |
searches | search_id | user_id | session_id | search_ts | query | is_bot | | 1001 | 1 | s1 | 2025-08-27 09:00:00 | jackets | FALSE | | 1002 | 2 | s2 | 2025-08-27 09:05:00 | bike | FALSE | | 1003 | 3 | s3 | 2025-08-27 09:10:00 | gadgets | FALSE | | 1004 | 1 | s1 | 2025-08-27 09:12:00 | jackets | FALSE | | 1005 | 2 | s4 | 2025-09-01 10:00:00 | helmet | FALSE | | 1006 | 2 | s5 | 2025-09-01 10:02:00 | helmet | TRUE |
search_results (deduplicate exact duplicate rows before use) | search_id | position | shop_id | clicked | | 1001 | 1 | 101 | TRUE | | 1001 | 2 | 103 | FALSE | | 1002 | 1 | 102 | TRUE | | 1003 | 1 | 103 | FALSE | | 1004 | 1 | 101 | FALSE | | 1004 | 2 | 103 | TRUE | | 1005 | 1 | 102 | FALSE | | 1005 | 11 | 103 | TRUE | | 1005 | 1 | 102 | FALSE | <-- duplicate row to test dedup | 1006 | 1 | 102 | TRUE |
Tasks