Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 arror near else keyword

Author  Topic 

rash901
Starting Member

8 Posts

Posted - 2014-11-12 : 06:06:17
m getting error "Incorrect syntax near the keyword 'else'"

please help m stuck below is my code



declare @a varchar(15), @b Float(12) ,@c Float(12),@m varchar(15),@n Float(15),@av Float(15),@xav float(15)
SELECT @a=reverse(Substring(reverse(remarks),Charindex('tS',REVERSE(remarks))+2,4))

FROM [IVRS_MIS].[dbo].[logs] where app_name='IVFRT_POC' and remarks like '%answered%'

if @a = 1020

SELECT @m = '1022', @n = Count(@a), @av = Count(@a)/4.0 ,@b = substring(MAX(right(node_info, charindex('X',reverse(node_info))-8)),1,5) ,@c=substring(MIN(right(node_info, charindex('X',reverse(node_info))-8)),1,5),@xav=(@b+@c)/2.0
FROM [IVRS_MIS].[dbo].[logs]
where APP_NAME='IVFRT_POC' AND remarks like '%No:1022Status:answered%'
select Distinct @m, @n,@av,@xav
FROM [IVRS_MIS].[dbo].[logs]

else if @a = 1021

SELECT @m = '1021', @n = Count(@a), @av = Count(@a)/4.0 ,@b = substring(MAX(right(node_info, charindex('X',reverse(node_info))-8)),1,5) ,@c=substring(MIN(right(node_info, charindex('X',reverse(node_info))-8)),1,5),@xav=(@b+@c)/2.0
FROM [IVRS_MIS].[dbo].[logs]
where APP_NAME='IVFRT_POC' AND remarks like '%No:1022Status:answered%'
select Distinct @m, @n,@av,@xav
FROM [IVRS_MIS].[dbo].[logs]

else if @a =1022


SELECT @m = '1022', @n = Count(@a), @av = Count(@a)/4.0 ,@b = substring(MAX(right(node_info, charindex('X',reverse(node_info))-8)),1,5) ,@c=substring(MIN(right(node_info, charindex('X',reverse(node_info))-8)),1,5),@xav=(@b+@c)/2.0
FROM [IVRS_MIS].[dbo].[logs]
where APP_NAME='IVFRT_POC' AND remarks like '%No:1022Status:answered%'
select Distinct @m, @n,@av,@xav
FROM [IVRS_MIS].[dbo].[logs]

else if @a=1023
SELECT @m = '1022', @n = Count(@a), @av = Count(@a)/4.0 ,@b = substring(MAX(right(node_info, charindex('X',reverse(node_info))-8)),1,5) ,@c=substring(MIN(right(node_info, charindex('X',reverse(node_info))-8)),1,5),@xav=(@b+@c)/2.0
FROM [IVRS_MIS].[dbo].[logs]
where APP_NAME='IVFRT_POC' AND remarks like '%No:1022Status:answered%'
select Distinct @m, @n,@av,@xav
FROM [IVRS_MIS].[dbo].[logs]

rash901
Starting Member

8 Posts

Posted - 2014-11-12 : 06:09:15
i got the answer just used begin and end ..
Go to Top of Page

rash901
Starting Member

8 Posts

Posted - 2014-11-12 : 06:09:16
i got the answer just used begin and end ..
Go to Top of Page
   

- Advertisement -