Plz help me to rectify the error:
Error: Incorrect syntax near the keyword 'As'.
Code:
declare @flag as int;
SET @flag='1';
SELECT Ci.iInstNumber AS InstNo,Ci.dInstDate AS InstDate, CASE WHEN (@flag='1')THEN SUM(Ci.fInstAmount+Ci.fShareProfit) ELSE Ci.fInstAmount As InstAmount END
Loading
anil johnPosted Nov 9, 2012, 5:12 AM
Shankar MPosted Nov 9, 2012, 4:57 AM
Here it is, The Alias name should be given after the CASE.. END statement like,
declare @flag as int;
SET @flag='1';
SELECT 1 InstNo,getdate() AS InstDate,
CASE WHEN (@flag='1')THEN SUM(1+1)
ELSE 2 END as InstAmount
Thanks,
Shankar