locked
Unique pairs of data RRS feed

  • Question

  • In my table, I have some duplicate rows. I want to select only the unique value pairs.

    So, the table/data look like this:

    ColumnA  -- ColumnB

    123  -- 234
    234  -- 345
    234  -- 345
    345  -- 456

    I want to create a select statement that will only return:

    123  -- 234
    234  -- 345
    345  -- 456

    In other words, the duplicate row i.e. the second 234 - 345 -- won't be included in the set my SELECT statement will return.

    Could someone help me with this SELECT statement? Thank you very much


    Thanks, Sam



    • Edited by imsam67 Wednesday, September 23, 2015 2:32 AM
    Wednesday, September 23, 2015 2:31 AM

Answers

  • SELECT DISTINCT ColumnA ,ColumnB from yourtable
    • Marked as answer by imsam67 Wednesday, September 23, 2015 2:54 AM
    Wednesday, September 23, 2015 2:52 AM

All replies

  • Is using DISTINCT the answer? I thought DISTINCT only affected the first column.

    Thanks, Sam

    Wednesday, September 23, 2015 2:38 AM
  • SELECT DISTINCT ColumnA ,ColumnB from yourtable
    • Marked as answer by imsam67 Wednesday, September 23, 2015 2:54 AM
    Wednesday, September 23, 2015 2:52 AM