讓我開始說是這是一個家庭作業問題。SQL僅列出子查詢中的唯一值
看起來很簡單,但我無法使它工作。我只是開始子查詢,我猜這就是我的老師在這裏想要的。
這裏的問題
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;
任何幫助,將不勝感激 - 謝謝!
我看到現在如何,非常感謝! – Taylor