让我先说是的,这是一个家庭作业问题。
它看起来很简单,但我无法让它工作。我刚刚开始子查询,我猜这就是我的老师想要的。
这是问题
5. 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 ProductName column.
这是我尝试过的
SELECT DISTINCT p1.ProductName, p1.DiscountPercent
FROM Products AS p1
WHERE NOT EXISTS
(SELECT p2.ProductName, p2.DiscountPercent
FROM Products AS p2
WHERE p1.DiscountPercent <> p2.DiscountPercent)
ORDER BY ProductName;
任何帮助将不胜感激 - 谢谢!