73.6k views
4 votes
Write a SELECT statement that returns the name and discount percent of each

--product that has a unique discount percent. In other words, don’t include products that --have the same discount percent as another product.
--Sort the results by the product_name column.

1 Answer

0 votes

Final answer:

To retrieve the name and discount percent of each product that has a unique discount percent from the products table and sort the results by product_name, you can use the provided SQL query.

Step-by-step explanation:

To retrieve the name and discount percent of each product that has a unique discount percent, you can use the following SQL query:

SELECT product_name, discount_percent FROM products WHERE discount_percent IN (SELECT discount_percent FROM products GROUP BY discount_percent HAVING COUNT(*) = 1) ORDER BY product_name;

This query first selects the discount_percent values that occur only once using a subquery. Then, it retrieves the product_name and discount_percent for those unique discount_percent values from the products table and sorts the results by product_name.

User Cursorrux
by
8.0k points

No related questions found