• Thanks again Michael,

    Yes you are absolutely right we have to use the group by clause and also I am stressed out too.

    On the select statement I added:

    ,FundedLastYear_Count

    I am still getting the error on line 31 (Line 31: Incorrect syntax near ','.)

    LEFT JOIN (SELECT

    Count(C2.AppID as FundedLastYear_Count, C.OldDealerID -----Line 31

    FROM Channels c

    LEFT JOIN Applications a ON c.ChannelID = a.SourceID

    LEFT JOIN Contracts2 c2 ON a.AppID = c2.AppID

    WHERE c2.DateContractFunded >= dateadd(yy, - 1, DATEADD(yy, DATEDIFF(yy, 0, getdate()), 0))

    AND c2.DateContractFunded < DATEADD(yy, DATEDIFF(yy, 0, getdate()), 0)

    GROUP BY C.OldDealerID) AS FundedLastYear ON C.OldDealerID = FundedLastYear.OldDealerID

    If we can solve this puzzle that would be the best thing ever