Cities with Properties
Management wants to map the cities where the company has properties. Return a list of distinct cities with at least one property. Sort the result alphabetically.
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 filtersManagement wants to map the cities where the company has properties. Return a list of distinct cities with at least one property. Sort the result alphabetically.
The senior animal care specialist is planning how to allocate animals to a new section and first wants to know the current population of the savanna section.
The zoo's conservation coordinator is preparing an educational banner about rare animals. Return the names and conservation statuses of species whose status is endangered or critically_endangered.
The annual reporting team is reviewing 2024 and wants a quick measure of the festival program’s size. Count the festivals in the database whose year is 2024.
Find all authors who viewed at least one of their own articles. Return each author’s identifier (author_id) in a result column named id. Sort the result in ascending order.
The food delivery team is evaluating delivery speed. Find the percentage of orders whose preferred delivery date is the same as the order date, meaning orders where order_date =…
Find the names of customers who were not referred by the customer with id = 2. Handle NULL values correctly: customers without a referrer must also be included.
A social media platform is building a dashboard to track activity on posts. The table contains both posts and comments. A post is a record where parent_id IS NULL.
Count the followers of each user. Return user_id and followers_count. Sort the result by user_id in ascending order.
Return the name and bonus of each employee whose bonus is less than 1000. Include employees who have no bonus, too.
The finance team needs a breakdown of sales by product. For each product, calculate the total quantity sold and return product_id and total_quantity.
Find all email addresses that appear in the table more than once.
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.