Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / February 2006

Tip: Looking for answers? Try searching our database.

urgent - Formating issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vp - 22 Feb 2006 20:41 GMT
Hi,

I have field QTY(Decimal 13,3) on the table and it might be +ve or -ve,
example below

QTY
----------
12.900
-12.900

I will have to make it to 10digits, which inclues decimal and NEGATIVE
sign

QTY
------
-0000012.9
00000012.9

Urgent advice needed
Tonkuma - 23 Feb 2006 02:01 GMT
------------------------------ Commands Entered
------------------------------
SELECT qty  AS Qty_13
    , SUBSTR(INSERT(CHAR(DEC(qty,9,1)),2,1-INT(SIGN(1+SIGN(qty))),'')
             ,1,10)  AS Qty_10
 FROM (SELECT CAST(src AS DEC(13,3))
         FROM (VALUES 12.900, -12.900, 10000000.000, 0.000,
12345678.999, -2345678.999) Q(src)
      ) R (qty);
------------------------------------------------------------------------------

QTY_13          QTY_10
--------------- ----------
        12.900 00000012.9
       -12.900 -0000012.9
  10000000.000 10000000.0
         0.000 00000000.0
  12345678.999 12345678.9
  -2345678.999 -2345678.9

 6 record(s) selected.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.