Home Forums SQL Server 2008 SQL Server Newbies How to select data (two columns) from table based on a composite unique value and insert in another table? RE: How to select data (two columns) from table based on a composite unique value and insert in another table?

  • Hi,

    Think this is what you're after, if I've read it right:

    SELECT c.CustomerNum, c.Source, COUNT(cm.*)

    FROM Contracts c

    INNER JOIN CustomerMaster cm ON cm.CustomerID = c.CustomerNum AND cm.Source = c.Source

    GROUP BY c.CustomerNum, c.Source

    Cheers

    Gaz