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:
I get why, but not sure how to solve. Any ideas?
Thanks,
Ben
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