Average Daily Removal Rate for Reported Posts
The moderation team is analyzing what percentage of reported posts eventually get removed.
Turn individual records into useful metrics with SQL aggregate functions practice. Count events, calculate totals and averages, group results by users or products, and filter groups based on their values. Your SQL runs in a real database, with results automatically checked against hidden data. Problems in this set: 266, free: 70.
Problems in this set: 266, free: 70
Start with a free problemProblems found: 97
Reset filtersThe moderation team is analyzing what percentage of reported posts eventually get removed.
A social network is analyzing follower-of-a-follower connections to identify users who follow someone else and also have followers of their own.
A bookstore is clearing slow-selling books from its catalog. Assume today is 2019-06-23.
The Central Election Commission is counting the votes to determine which candidate received the most. Find the election winner and return that candidate's name.
The warehouse system does not store current stock in a separate column. Instead, every stock receipt and withdrawal is recorded as a separate row in inventory_events.
Find the IDs of products that were sold only during the first quarter of 2019, from January 1 through March 31, inclusive. Exclude any product that has at least one sale outside the range 2019-01-01..
A brokerage firm is preparing a report on portfolio trading results.
The finance department analyzes transactions based on whether their amounts are odd or even.
The finance department is preparing a quarterly sales summary to compare revenue across periods of the year. For each quarter from 1 to 4, calculate the total sales amount.
HR is checking for overbooking and potential conflicts in employee calendars. Find employees who have more than one booking on the same day. Return employee_id and employee_name.
A logistics manager is preparing a list of stores at risk of running out of stock. Find stores where at least one item's quantity is below its minimum stock level: quantity < min_stock.
The loyalty team wants to identify repeat customers who placed orders on different days. Find customers who placed orders on at least 3 distinct dates.
Adding an unnecessary column to GROUP BY can split one expected group into several. Leaving out a required column can combine unrelated records. Define what one output row should represent, such as a user, product, day, or combination of dimensions, before building the aggregation.
COUNT(*) counts rows, while COUNT(column) ignores rows where that column is NULL. The difference matters whenever data is missing. Compare the counts on a small sample and decide whether the task requires every record or only records with a non-NULL value.
WHERE filters individual rows before aggregation. HAVING filters groups after aggregate values have been calculated. If you need products with a minimum number of purchases, removing rows too early can change the result. Separate conditions on source records from conditions on grouped metrics.
A JOIN can multiply records before aggregation. For example, an order may appear several times when joined to a table containing multiple related entries. That can inflate totals without producing an obvious error. Check the join keys and the number of underlying records being counted.
Your SQL executes in a real database, and the resulting data is automatically compared with an expected result using hidden data. A correct query must handle more than the obvious cases, including missing values, repeated records, and groups of different sizes.
Yes. Free problems in this collection: 70. Once signed in, you can solve up to 3 new problems per day on the free plan. Premium problems are listed alongside them, but solving those requires a subscription.
Use WHERE for conditions on individual records before grouping, such as restricting events to a particular date range. Use HAVING when the condition depends on an aggregate result, such as total sales. A single query can use both to filter source data and then filter groups.
You may be counting events when the problem asks for unique users or orders. Duplicate records and joins can also increase the total. Check what each row represents and whether NULL values matter. Match the counting method to the exact entity described in the question.
GROUP BY combines source rows into aggregated results, typically one row per group. Window functions calculate values across related rows without necessarily collapsing the original rows. Choose GROUP BY when you need a summary and window functions when individual records must remain visible.