• Walton (8/19/2013)


    Hi all,

    I need a help on getting the distinct set.

    My Data look like this:

    SET 1

    SET ID Product Attribute

    1 A 10

    1 A 11

    SET 2

    SET ID Product Attribute

    2 A 10

    2 A 12

    SET 3

    SET ID Product Attribute

    3 A 10

    3 A 11

    Since set ID 1 and 3 has the same product and attribute I just need to get distinct set having the same product and attribute. The result set will look like this

    SET ID Product Attribute

    1 A 10

    1 A 11

    2 A 10

    2 A 12

    Thank you all in advance for your help.

    So what happens to Set 3? The product/attribute combination is both Set 1 and 3 but how to decide which Set to use?

    Maybe as simple as using MIN?

    You didn't provide anything usable so my code probably doesn't work as is.

    select min(setid), Product, Attribute

    From SomeTable

    group by Product, Attribute

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/