T-SQL: Omit/Ignore repetitive data from a specific column
Posted
by Dsyfa
on Stack Overflow
See other posts from Stack Overflow
or by Dsyfa
Published on 2010-03-03T11:40:24Z
Indexed on
2010/05/17
3:00 UTC
Read the original article
Hit count: 330
Hi,
For my question lets consider the following sample table data:
ProductID ProductName Price Category
1 Apple 5.00 Fruits
2 Apple 5.00 Food
3 Orange 3.00 Fruits
4 Banana 2.00 Fruits
I need a query which will result in the following data set:
ProductID ProductName Price Category
1 Apple 5.00 Fruits
3 Orange 3.00 Fruits
4 Banana 2.00 Fruits
As you can see ProductID 2 has been omitted/ignored because Apple is already present in the result i.e. each product must appear only once irrespective of Category or Price.
Thanks
© Stack Overflow or respective owner