'Apply formula to first row
I am trying to apply one formula to the first row in my table and apply a different formula for the remaining rows.
I am getting an error
Msg 156, Level 15, State 1
Incorrect syntax near the keyword "Case"
Code:
SELECT
[Total Money Invested]
FROM
[dbo.SPY_HISTORY1],
CASE
WHEN id = 1 THEN [Total Money Invested] * (1 + [Return])
ELSE [Portfolio_Remaining] * (1 + [Return])
END AS [Equity_Portfolio];
END
FROM
[dbo.SPY_HISTORY1];
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
