• tsmith-960032 (9/22/2010)


    Daniel Bowlin (9/22/2010)


    Try a CTE or temp table to get your DISTINCT then join that back to a SELECT where you query the data and constrain on the MIN or MAX of Column C

    Thank you for your reply.

    I solved my issue as follows :

    Select Distinct ColumnA, Max(ColumnB) As ColumnB, Max(ColumnC) As ColumnC

    From SoAndSoTable

    Group By ColumnA

    Thanks again Daniel, and of course Thank You Luke.

    Sorry, for the late reply, but yes that's why I was trying to get at. When you do your grouping you need to decide which results you want from Columns b and c. The MAX() function will get you there.

    Glad it worked out for you, however using the DISTINCT Keyword and a GROUP BY clause is redundant and I'm somewhat amazed that SQL doesn't throw an error here. I understand that it doesn't 'cause I just tested it, but it still seems like something strange and perhaps may cause you issues down the road. I'd remove the DISTINCT Keyword and just stick with the GROUP BY clause for clarity.

    -Luke.

    To help us help you read this[/url]For better help with performance problems please read this[/url]