July 13, 2005 at 9:23 am
I keep getting a syntax error near ')' for the following - can anyone help please??
CREATE PROCEDURE sp_getInfo
AS
--Begin
Select Office, tab, title,
round(SUM(curno),2) as CurNo,
round(sum(prevno),2) as PrevNo, TabOrder, SortOrder
from
(select Office1, Tab, title,
(case isyear when 2005 then (No*Percent1) else 0 end) AS CurNo,
(case isyear when 2004 then (No*Percent2) else 0 end) AS PrevNo,
TabOrder, SortOrder from vwData A
where Mnth between 1 and @Month and IsYear in (@Year, @Year-1) and Office1 = @office )
--end
July 13, 2005 at 9:37 am
When you use a derived table you need to give it a name or alias.
CREATE PROCEDURE sp_getInfo
AS
--Begin
Select Office, tab, title,
round(SUM(curno),2) as CurNo,
round(sum(prevno),2) as PrevNo, TabOrder, SortOrder
from
(select Office1, Tab, title,
(case isyear when 2005 then (No*Percent1) else 0 end) AS CurNo,
(case isyear when 2004 then (No*Percent2) else 0 end) AS PrevNo,
TabOrder, SortOrder from vwData A
where Mnth between 1 and @Month and IsYear in (@Year, @Year-1) and Office1 = @office ) AS MyDerivedTable
July 13, 2005 at 9:39 am
THANK YOU!
July 13, 2005 at 10:05 am
One IMPORTANT ITEM.
NEVER name your stored-procedures sp_ .... This will cause performance problems and you will start getting confused as to what did I create v. Microsoft create.
Good Hunting!
AJ Ahrens
webmaster@kritter.net
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply