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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dividing decimal by decimal in SQL

Status
Not open for further replies.

sivi

IS-IT--Management
Nov 27, 2002
27
GB
Hi
I would be grateful for any help.

I need to divide a decimal field by another decimal field. These 2 fields (atick & amin) are set up as VARCHAR fields. I converted both of them as follows:

select cast (atick as decimal(10,9)) / cast(amin as decimal(10,9)) from mytable

BUT getting the following error:
'Arithmetic overflow error converting numeric to data type numeric.'
sample values for both:
atick:- 5.0000,1000.0000, 3.3000, 6.0000,15.6250
amin:- 0.05000000,10.0000000, 0.01000000, 0.20000000, 0.01562500

Any help would be greatly appreciated.
Many thanks
Sivi
 
The decimal(10, 9) means that you want max. 10 digits (both to the left and to the right of the decimal point, and 9 digits to the rigth of the decimal point, so on the left side can be 1 digit maximum. That's why you get error. You should use ie. decimal(18, 9).

Otto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top