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.
| Author |
Topic |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2009-12-18 : 12:14:11
|
| I'm getting incorrect syntax near 'sum'ALTER PROCEDURE [dbo].[GetAreaWeek] --'c', '01'@Region_LTR varchar (1),@Area char(2)AsSET NOCOUNT ONSelect Casewhen sort = 'x' then 'Area ' + right(Region_LTR,1)else Region_LTRend AS reg1, [Perc Received] = Casewhen co = 0 then '0'when cr = 0 then '0'else convert (varchar,(cr * 100/co * 100)/100) end + '%',Ans, [Perc Ans] = Casewhen cr = 0 then '0'when Ans = 0 then '0'else convert(varchar,(ans * 100/cr * 100)/100) end + '%', OverFlow,[Perc Overflow] = Casewhen cr = 0 then '0'when overflow = 0 then '0'else convert(varchar,(overflow * 100/cr * 100)/100) end + '%',Aband,[Perc Aband] = Casewhen cr = 0 then '0'when Aband = 0 then '0'else convert(varchar,(Aband * 100/cr * 100)/100) end + '%', Busy,[Perc Busy] = Casewhen co = 0 then '0'when Busy = 0 then '0'else convert(varchar,(Busy * 100/co * 100)/100) end + '%' select sum(CO) as COsum(CR) as CR, sum(Ans) as Ans,sum(Overflow) as OverFlow,sum(Aband) as Aband,sum(Busy) as Busy, convert(varchar,dowrdate,1) as dowrdatefrom TSRPtotalswhere (sort='1') or (sort = @Region_LTR) or (Region_LTR= @Region_LTR and area = @Area and sort = 'x' and doc='000') or (Region_LTR= @Region_LTR and area = @Area and sort = 'z') |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2009-12-18 : 13:17:38
|
| select sum(CO) as CO,sum(CR) as CR, sum(Ans) as Ans,sum(Overflow) as OverFlow,sum(Aband) as Aband,sum(Busy) as Busy, convert(varchar,dowrdate,1) as dowrdatefrom TSRPtotalswhere (sort='1') or (sort = @Region_LTR) or (Region_LTR= @Region_LTR and area = @Area and sort = 'x' and doc='000')or (Region_LTR= @Region_LTR and area = @Area and sort = 'z') |
 |
|
|
|
|
|
|
|