Extract the domain from clicked_url: trim spaces and lower-case it; remove the scheme (anything up to and including '://', if present); remove ONE leading 'www.' if present; then cut at the first '/', '?', '#' or ':' (port). Queries are compared after LOWER(TRIM(query)). Return domain, clicks and distinct_queries. Order by clicks DESC, then domain.
| Column | Type |
|---|---|
| click_id | INTEGER |
| query | TEXT |
| clicked_url | TEXT |
| click_id | query | clicked_url |
|---|---|---|
| 1 | sql joins | https://www.techdocs.io/sql/joins |
| 2 | sql joins | http://techdocs.io/sql |
| 3 | window functions | https://blog.datahub.dev/windows?ref=g |
| 4 | SQL joins | https://www.techdocs.io |
| 5 | cte | https://blog.datahub.dev/cte |
| 6 | pivot | https://qa.forum.net/q/123 |
| domain | clicks | distinct_queries |
|---|---|---|
| techdocs.io | 3 | 1 |
| blog.datahub.dev | 2 | 2 |
| qa.forum.net | 1 | 1 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Peak Concurrent Meetings per Org · Friend Suggestions by Mutual Friends ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.