Retrieving multiple rows in SQL Server but distinct filtering only on one
- by Nicklas
I have this:
SELECT Product.ProductID, Product.Name, Product.GroupID, Product.GradeID,
AVG(tblReview.Grade) AS Grade
FROM Product left Join tblReview ON Product.GroupID = tblReview.GroupID
WHERE (Product.CategoryID = @CategoryID)
GROUP BY Product.ProductID, Product.Name, Product.GroupID, Product.GradeID
I would like to return only the rows where Product.Name is unique. If I make a SELECT DISTINCT the ProductID is different on every row so all the rows are unique.