Drug Sales by Manufacturer
CVS Health is summarizing drug sales by manufacturer. For each manufacturer, calculate the total sales amount.
Build confidence writing queries with MySQL practice problems designed for MySQL 8.4. Start with selecting and filtering records, then explore joins, aggregate functions, and other SQL features. Your queries execute in a real MySQL database, and the trainer automatically checks the output against expected results using hidden data. Problems in this set: 324, free: 106.
Problems in this set: 324, free: 106
Start with a free problemProblems found: 106
Reset filtersCVS Health is summarizing drug sales by manufacturer. For each manufacturer, calculate the total sales amount.
The band's management wants to know how often the tour features club shows because that affects the marketing budget. Count all concerts held at venues of type Club.
The pharmacy is reviewing its price tags. Return the name and price columns for all medications costing more than 6 euros. Sort the result by price in descending order, from most to least expensive.
Amazon is analyzing monthly trends in product ratings. For each month and product_id pair, calculate the product's average rating.
manThe team running a pre-concert trivia quiz is looking for fans whose names end in man, as a nod to the band's track with that title. Return those fans' names.
Alibaba stores order counts in a compressed table: for each number of items per order, it records how many orders had that item count.
The HR department is looking for pay anomalies: some employees earn more than their immediate managers. Find all such employees and return their ID and name.
JPMorgan Chase is preparing a credit card issuance report. For each card, calculate the difference between the highest and lowest numbers of cards issued in a month. Return card_name and difference.
The partner marketing team wants to reach Hotmail users for a themed promotion. Return all columns for passengers whose email addresses are in the hotmail.com domain.
A tour promoter needs a complete list of registered fans to send invitations to a private performance. Return the names of all fans in the database.
The real estate team is preparing an overview of the Moscow market. Return all columns for properties located in the city of Moscow.
The Microsoft Azure team is evaluating unused data center capacity. For each data center, calculate spare capacity as monthly_capacity − monthly_demand. If demand data is missing, treat demand as 0.
MySQL 8.4 does not support FULL OUTER JOIN directly. Copying a query that uses this operator from another SQL dialect will fail. Before choosing an alternative, decide whether you need matching rows, all records from one table, or unmatched records from both sides.
GROUP_CONCAT combines values into a string, but their order is not guaranteed unless you specify it. Two results can contain the same elements in different sequences. If order matters, define it inside the aggregate function and test groups containing several distinct values.
IFNULL replaces a NULL value with a chosen alternative. However, zero, an empty string, and missing data do not always mean the same thing. Replacing missing values before calculating an aggregate can change the metric. Decide when the substitution should happen and why.
LIMIT controls how many records are returned, not which ones rank highest or lowest. Without ORDER BY, MySQL does not guarantee a particular row order. Specify the sorting criteria first, and consider what should happen when multiple records have equal values.
The exercises in this collection support MySQL 8.4. Queries run in a real database, and results are automatically checked against expected output using hidden data. When adapting SQL from another database system, pay attention to differences in functions, joins, and date handling.
Yes. Free MySQL problems: 106. After signing in, you can solve up to 3 new problems per day on the free plan. Premium exercises are visible in the list but require a subscription. Reference SQL solutions are not published.
Yes. MySQL has supported window functions since version 8.0, so they are available in MySQL 8.4. They let you calculate ranks, running values, and other metrics across related rows without necessarily reducing each group to a single result row.
IFNULL changes the value returned by an expression when that value is NULL. WHERE determines which rows belong in the result. Use a replacement when you want to keep the record with a fallback value, and a filter when records should be excluded.
MySQL 8.4 has no native FULL OUTER JOIN operator. If you need matching and unmatched records from both tables, you must combine supported SQL operations to produce that result. Be careful with duplicates and determine whether each matching pair should appear once.