SELECT DISTINCT

  • Brain has gone blank....

    how would you do a select distinct but where you want distinct values from one column but then you want all other columns from the table the problem being one of the other columns has unique values...

    hope I have worded this ok.

  • Hi Geoff - please provide three or four lines of source data and then an example of the results that you would like, based on that data.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Not possible as the 'unique column' will prevent distinction

    You will either have to

    ignore the 'unique column' e.g.

    SELECT col1,col2,col3 FROM

    GROUP BY col1,col2,col3

    or aggregate the 'unique column' e.g.

    SELECT col1,col2,col3,MIN([unique column]) FROM

    GROUP BY col1,col2,col3

    It would help if you could post DDL, sample data and expected output to better understand your requirements.

    Darn, Phil beat me to it

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

  • See http://qa.sqlservercentral.com/forums/shwmessage.aspx?forumid=169&messageid=248544 which is another example of the same requirement.

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

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