• This should help

    WHERE a.connected = 0 AND ( dt.connected IS NOT NULL OR b.id IS NULL )

    Even the below code will solve your requirement if you are using SQL Server 2005+

    SELECT*

    FROMforums AS a

    LEFT OUTER JOIN(

    SELECTROW_NUMBER() OVER ( PARTITION BY connected ORDER BY datum_updated DESC ) AS RN, *

    FROMforums

    ) b ON a.id = b.connected AND b.RN = 1

    WHEREa.connected = 0

    Edit: Added alternate code


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/