distinct values , but for only first column not for others !!!!

  •  

         I want to display the whole table but with distinct value for the first column. When i'm doing this 'select distinct phone_number from temp_table' then it display only the first column. I want to display the whole three column but with the condition of distinct phone_number only.

       could anyone help me out please........

  • not able to get your  requirement. if there are 10 records in table, with 3 distinct phone_numbers, how your results should look ??

    can you put an example of what you want ?

     


    -- Amit



    "There is no 'patch' for stupidity."



    Download the Updated SQL Server 2005 Books Online.

  •  

      thnaks for reply....

     

       I want to display the whole data, but with distinct first column.....

    I mean only the first colmn is primary key irrespective of the others three columns. I want to display the whole data but with distinct first_column.......

    suppose my entries are like :

    911111111111, good, english

    911111111111, bad, english

    912222222222, good, english

    913333333333, bad, hindi

    911111111111, good, malayalam

    912222222222, good, english

    ..................

     when i write query it should display as :

    911111111111,good,english

    912222222222,good, english

    913333333333, bad, hindi

    i mean to say that of the result of distinct phone_number it should display with the other two columns......

    i want to have the phone_number should be distinct irrespective of the other two column( wheather it's same or not , don't mind)........

    please help me out .......

  • So may be you don't care about the values in next 2 columns. or their relation with the phone number column. you may want to revisit you table designs.

    try this.

    select phone, min (col1), min(col2)

    from table

    group by phone


    -- Amit



    "There is no 'patch' for stupidity."



    Download the Updated SQL Server 2005 Books Online.

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

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