July 26, 2013 at 11:41 pm
Dear friends,
need your help-
calculation - round to closest integer:
(((Monthly Revenue field - Monthly Cost field )/Monthly Revenue field) * 100)
--> how to do this please?
thanks
DJ
July 27, 2013 at 2:04 am
convert(int, round(((Monthly Revenue field - Monthly Cost field )/Monthly Revenue field) * 100), 2))
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
July 27, 2013 at 12:21 pm
Hi Erland,
this is giving me error:
-------
Msg 8117, Level 16, State 1, Line 11
Operand data type nvarchar is invalid for subtract operator.
--------
since I see that the 2 fields "Monthly Revenue, and Monthky Cost" in the database are of datatype nVacrhar, hence if you can help me.
Below is the requirment again for your refrence-
ound to closest integer:
(((Monthly Revenue field - Monthly Cost field )/Monthly Revenue field) * 100)
July 27, 2013 at 3:00 pm
This is a forum for SQL questions, not for telepathy. If you don't include table and column definitions, the answers you get will be based on wild guesses.
If these columns are supposed to include numbers, why are they nvarchar? What are the typical values you have in those columns?
For this type of problem, it's often a good idea to post:
1) CREATE TABLE statements for the tables.
2) INSERT statements with sample data.
3) The desired result given the sample.
4) Which version of SQL Server you are using.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply