Probably easy SQL but urgent

Fairly simple here, probably.  Percent Goal, Units_data_warehouse, and OEM_Goal are all integers.  When I get my output, Percent goal is either 0 or 100.  I assume this is because of data types, but every attempt to fix it has resulted in arithmetic overflow or some other error.  
UPDATE 	#output
	SET Percent_Goal = ((Units_Data_Warehouse / OEM_Goal) * 100)

Open in new window

LVL 9
zkeownAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
UPDATE  #output
        SET Percent_Goal = (( cast(Units_Data_Warehouse as decimal(10,2) )  / OEM_Goal) * 100)
0
Jinesh KamdarCommented:
Try this.

UPDATE #output
SET Percent_Goal = (Units_Data_Warehouse * 100) / OEM_Goal
0
chapmandewCommented:
UPDATE  #output
        SET Percent_Goal = ((CAST(Units_Data_Warehouse AS FLOAT)/ CAST(OEM_Goal AS FLOAT) * 100.00)
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

zkeownAuthor Commented:
Wow.  OK all solutions are close, however if the math evaluates to 4.6 I'm getting 4 and I need 5.
0
Jinesh KamdarCommented:
Use CEIL function.

UPDATE #output SET Percent_Goal = CEIL((Units_Data_Warehouse * 100) / OEM_Goal);
0
Aneesh RetnakaranDatabase AdministratorCommented:
UPDATE  #output
        SET Percent_Goal =  ROUND ( (( cast(Units_Data_Warehouse as decimal(10,2) )  / OEM_Goal) * 100) , 2)
0
Aneesh RetnakaranDatabase AdministratorCommented:
ooops

UPDATE  #output
        SET Percent_Goal =  ROUND ( (( cast(Units_Data_Warehouse as decimal(10,2) )  / OEM_Goal) * 100) , 0)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zkeownAuthor Commented:
Neither is working... For instance one row has

Units_data_warehouse = 2
OEM_Goal = 43

2 / 43 = .0465...  * 100 = 4.65

But says 4.

0
zkeownAuthor Commented:
Ah ha!  Thanks aneeshattingal!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.