Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot perform and aggregate function on an expression...

Status
Not open for further replies.

xavstone

Technical User
Apr 12, 2005
33
GB
I am getting the error: "Cannot perform and aggregate function on an expression containing an aggregate or a subquery."

on this portion of my query:

Code:
(SELECT SUM(

CASE 
WHEN closeDate > '1950-01-01' THEN closePrice
WHEN closeDate < '1950-01-01' THEN

(SELECT dbo.symbolData.priceClose
FROM dbo.dates
INNER JOIN dbo.symbolData ON dbo.dates.id = dbo.symbolData.dateId
INNER JOIN dbo.position ON dbo.symbolData.symbolId = dbo.position.symbolId
WHERE dbo.dates.priceDate = MAX(dbo.dates.priceDate))

END

- openPrice) FROM dbo.position WHERE IsLong = 'TRUE' AND closeDate > '1950-01-01') as 'Total Long Profit',

I get why, but not sure how to solve. Any ideas?

Thanks,
Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top