DISTINCT Values

  • Hi All,

     

    Gotta a problem.

    I have a table with the following data ( Column names are G1 / G2 / G3 / G4)

    B E B A

    B E B B

    B E B D

    B E B F

    B E C A

    B E C A

    B E C B

    B E C D

    B E C F

    B E F A

    I want to return only the rows where all 4 values are different.

    Can't seem to make this happen, anyone have a suggestion ?

    Dave

     

     

     

  • Hi Dave,

    Try this:

    select distinct G1, G2, G3, G4
    from table

    Hope that helps,

  • Hi Dave, perhaps you mean just the unique rows, in that case try

    select g1,g2,g3,g4
    from mytable
    group by g1,g2,g3,g4
    having count(*)=1;
  • SELECT DISTINCT G1,G2,G3,G4

    FROM

    WHERE (G1 <> G2 AND G1 <> G3 AND G1 <> G4)

    AND (G2 <> G3 AND G2 <> G4)

    AND (G3 <> G4)

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Hi, All

    Just wanted to thank everyone for their help.

    All the Best

    Dave

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply