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!

Division/Multiplication rounding in SQL 1

Status
Not open for further replies.

RiverGuy

Programmer
Joined
Jul 18, 2002
Messages
5,011
Location
US
UPDATE Table1 SET Table1.Field3 = (Table1.Field2/Table1.Field1)

Yeilds a figure rounded off to the nearest whole number. And I'm working with percents, so its either 100 percent or 0 percent.

But if I do a select statement to just show that division, it comes out perfect.]


Any ideas? My temporary fix was to first multiply that division in the parentheses by 100, and then I would get a number from 0 to 100, and a percentage could be inferred if you wanted it to look at it that way, but I would rather have a true decimal.
 
Riverguy,

Check the field type of Field3. It's probably an integer. It needs to be a single or double, or if you are working with percentage, you can just use the currency type and it will be accurate to the hundredth place.

HTH

Will
 
OK, I'll check it. I had tried integer and decimal I believe so far.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top