Retrieving multiple rows in SQL Server but distinct filtering only on one
Posted
by Nicklas
on Stack Overflow
See other posts from Stack Overflow
or by Nicklas
Published on 2010-05-11T14:55:03Z
Indexed on
2010/05/11
15:14 UTC
Read the original article
Hit count: 265
sql-server
|sql
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.
© Stack Overflow or respective owner