query_frequencies has one row per search term (term, frequency). Treat the table as a compressed list in which each term's frequency value is repeated frequency times (a term with frequency 3 contributes the values 3, 3, 3). Compute the median of that expanded list without a MEDIAN function: with N values sorted ascending, the median is the middle value when N is odd and the average of the two middle values when N is even. Output a single column: weighted_median_frequency (rounded to 1 decimal).
| Column | Type |
|---|---|
| term | TEXT |
| frequency | INTEGER |
| term | frequency |
|---|---|
| A | 5 |
| B | 3 |
| C | 2 |
| weighted_median_frequency |
|---|
| 4 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
{{ 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.