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 > Number conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-04-04, 05:24
Zcumbag Zcumbag is offline
Registered User
 
Join Date: Apr 2004
Posts: 31
Number conversion

Hi all!

I have a int-column that stores large numbers in my table and I want the output from a SELECT-statement to output it diffrent...

If the number is 6 100 000 The output should be 6.1 and 19 000 000 should be 19.1

I would also like the numbers to be rounded to the closest 100 000 (round(myInt, -5) right?)

thanks guys!
Reply With Quote
  #2 (permalink)  
Old 11-04-04, 09:55
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
Is this what your after

SELECT ROUND(Cast(Number as Decimal)/1E6,1)

Dave
Reply With Quote
  #3 (permalink)  
Old 11-04-04, 12:28
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
I'd suggest using:
Code:
SELECT Cast(myColumn / 1e6 AS DECIMAL(6, 1))
-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