If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Number of decimals in SQL field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-15-04, 18:44
JohnStrecker JohnStrecker is offline
Registered User
 
Join Date: Sep 2004
Posts: 39
Number of decimals in SQL field

Hi !

How can I define the number of decimals in an SQL field ?

I have a currency field (1 EUR = 0.82 USD) and an inverted currency field (USD 1.21 = 1 EUR)

The trouble is that when I ask SQL to calculate 1/0.82 I get 1.2195122

Any suggestion anyone ?

Many thanks from Belgium

John
Reply With Quote
  #2 (permalink)  
Old 09-16-04, 05:29
RBARAER RBARAER is offline
Registered User
 
Join Date: Aug 2004
Location: France
Posts: 754
Hello,

Use the ROUND function, for example :

SELECT ROUND(1/0.82, 2) FROM DUAL;

returns 1,22 (2 decimals)

SELECT ROUND(1/0.82, 4) FROM DUAL;

returns 1.2195 (4 decimals)

Regards,

RBARAER
Reply With Quote
  #3 (permalink)  
Old 09-18-04, 12:22
JohnStrecker JohnStrecker is offline
Registered User
 
Join Date: Sep 2004
Posts: 39
Many thanks RBARAER

Have a cool week-end!

John
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On