Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Posts
    29

    Question Unanswered: Distict on single column??

    Is there any way I can use 'distinct' on first column instead of complete row?

    Consider following data.

    col1-col2-col3
    1-A-AA
    1-A-AB
    1-B-AA
    2-A-AA
    2-B-BA

    Now I want to results as follows.

    1-A-AA
    2-A-AA

    How can I achieve this?

  2. #2
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    Hiya nmr,

    1> create table t2(c1 int, c2 char(1), c3 char(2))
    2> go
    1> insert into t2 values(1, "A" ,"AA")
    2> insert into t2 values(1, "A" ,"AB")
    3> insert into t2 values(1, "B" , "AA")
    4> insert into t2 values(2, "A", "AA")
    5> insert into t2 values(2, "B" , "BA")
    6> go
    1> select c1, min(c2) "c2" , min(c3) "c3"
    2> from t2
    3> group by c1
    4> go
    c1 c2 c3
    ----------- -- --
    1 A AA
    2 A AA

    Cheers
    Willy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •