Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cast/convert arithmetic issue

Status
Not open for further replies.

BHScripter

Technical User
Joined
Aug 26, 2002
Messages
159
Location
US
Hi:

I have the following code and I keep getting an error:
Incorrect syntax near ')'.


Cast(Convert(decimal(8,0),100*((u.srent) - sum(isnull(cr.destimated,0)/u.srent)))As varchar) + '%')Percent_Variance,

What am I doing wrong? I looked at a post similar to this and thought I was doing this correctly alas...

Thanks in advance
 
Remove last ')', the one before Percent_value alias.

------
heisenbug: A bug that disappears or alters its behavior when one attempts to probe or isolate it
schroedinbug: A bug that doesn't appear until someone reads source code and realizes it never should have worked, at which point the program promptly stops working for everybody until fixed.

[ba
 
you have 7 (
and 8 )
Somewhere you have missed a left bracket or added a right one
 
That worked...sort of. I know the issue is now between my formula and the decimal conversion.

Example my prior formula which didn't try to convert it to varchar (which i need because those requesting the report want it to round off without any decimal places and a % sign)

Anyway my first formula:
((((u.srent) - sum(isnull(cr.destimated,0)))/u.srent))*100 Perc_Variance

gave me results like 8.32, 10.12 etc.
my goal is to get to 8%, 10%

When I use the script I first posted and make the changes suggested, I get 84908%, etc.

Any help would be greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top