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 > Data Access, Manipulation & Batch Languages > ANSI SQL > convert value to 2 digits after decimal

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-05-04, 05:32
Raisor Raisor is offline
Registered User
 
Join Date: Feb 2004
Posts: 5
convert value to 2 digits after decimal

I'm having a query as follows:
SELECT 41.78 * 0.01 * 17 + 41.78 AS new_price

it returns 48.8826, but how do I set it up that it would round it nicely to two digits? as of 48.88

THANKS!
Reply With Quote
  #2 (permalink)  
Old 03-05-04, 07:23
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: convert value to 2 digits after decimal

In Oracle you would use ROUND(value,2).
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 03-05-04, 12:47
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Just an observation, but rounding is really a client-side issue. In all but a few cases, it should really be handled by the client instead of the server.

Most servers will accept the:

SELECT Round(41.78 * 0.01 * 17 + 41.78, 2) AS new_price

syntax, but you still should do the rounding at the client if you can. Someday you might decide that you want the "full value", or maybe you'll need to round at a different precision than 2 for some clients... Not that I've ever had that happen, I just read about it in a book once.

-PatP
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