Thanks for all the help so far.
Initially I thought once I had the query set up, it'd be easy to put a WHERE clause in (for this purpose I'm attempting to limit to [# of Securities] > 70 OR SumOfMV > 100
SELECT A.Portfolio, B.PortfolioID, SUM(B.MarketValue) AS SumOfMV,
COUNT(B.SecID) AS [# of Securities]
From ERTutAccounts A
INNER JOIN ERTutPositions B ON A.PortfolioID = B.PortfolioID
WHERE COUNT(B.SecID) > 70 OR SUM(B.MarketValue) > 100
GROUP BY A.Portfolio, B.PortfolioID
The error is as follows:
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
I would like to learn this stuff, because I am going to eventually be using it everyday. Is there a good place to start?