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.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • 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://www.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