• Thanks for the reply. My query gives a single row. Yours gives me multiple rows. But my query has 2 objects in the FROM clause instead of a JOIN, joining the results from the subquery to the rest of it.

    I Do think I have found the answer to my own question. It does work:

    SELECT a.ProcDate, MAX(b.DayKey) DayKey

    FROM dbo.MyTable a

    INNER JOIN ( SELECT MAX(DayKey) DayKey

    FROM dbo.MyTable

    WHERE ExtractType = 'D'

    ) b

    ON a.DayKey = b.DayKey

    WHERE ( a.ExtractType = 'D' )

    GROUP BY a.ProcDate

    Let me know if you think this would be correct in general.