• prady_1988 (10/5/2012)


    Mark-101232 (10/5/2012)


    Try this

    SELECT AssetID, AssetName, MAX(Relationship) AS Relationship, MAX(Company) AS Company

    FROM myTable

    GROUP BY AssetID, AssetName

    Thanks Mark, but the problem is "Relationship" and "Company" columns are from different tables. Hence using two Select queries with a Union

    Where as AssetID and AssetName are from a single table. Therefore there are 3 tables involved

    Perhaps you could post the DDL for the tables. Meanwhile, this may work

    SELECT t.AssetID, t.AssetName, r.Relationship, c.Company

    FROM myTable t

    LEFT OUTER JOIN RelationshipTable r ON r.AssetID = t.AssetID

    LEFT OUTER JOIN Company c ON c.AssetID = t.AssetID

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537