can keep the zeroes right of a decimal number

Hi all

Is there a way that I can keep the zeroes right of a decimal number;
for example. My data looks like this;
1.45600000
2.45140000
3.00000000

and the output instruction select look like below.
1,456
2.4514
3

I want the output to represent the actual data 0 right.

Thank you

Is that what you are looking for:

SQL> create table t(num number(9,8))
  2  /

Table created.

SQL> insert into t
  2  select 1.456 num from dual union all
  3  select 2.4514 from dual union all
  4  select 3 from dual
  5  /

3 rows created.

select  to_char(num,lpad('9',whole,'9') || case when fractional > 0 then '.' || lpad('9',fractional,'9') end) num
  from  t,
        (
         select  data_precision - data_scale whole,
                 data_scale fractional
           from  user_tab_columns
           where table_name = 'T'
             and column_name = 'NUM'
        )
/

NUM
-----------------------------
 1.45600000
 2.45140000
 3.00000000

SQL> 

If you wish to format it is based on real data:

with t as (
           select 1.456 num from dual union all
           select 2.4514 from dual union all
           select 3 from dual
          )
select  to_char(num,lpad('9',whole,'9') || case when fractional > 0 then '.' || lpad('9',fractional,'9') end) num
  from  t,
        (
         select  nvl(max(length(regexp_replace(num,'\..*$'))),0) whole,
                 nvl(max(length(regexp_replace(num,'^.*\.'))),0) fractional
           from  t
        )
/

NUM
-------------------
 1.4560
 2.4514
 3.0000

SQL> 

SY.

Tags: Database

Similar Questions

  • Convert hexadecimal into decimal and keep the zeros on the left...

    Hello

    I hope you can help us?

    How to convert hex to Decimal and keep the zeros

    I read 002C, hex, and I want to convert it to decimal-0044.

    sscanf (MyNum, % '4 x', & DecNum); will only give me 44.

    It worked until I started having zeros.

    We will always have a 4 digit hexadecimal entry in a range

    We have the 00 leader in this case.

    How is this best?

    Thanks for the help

    Simon

    Hello

    I don't really understand your problem. Is this kind of things that you need?

    int main (int argc, char *argv[])
    {
        const char MyNum[] = "002C";
        int DecNum;
    
        sscanf (MyNum, "%4x", &DecNum);
        printf ("%04d", DecNum);
        getchar ();
    
        return 0;
    }
    

    '0044' appears on standard output when executing the printf function...

  • cfspreadsheet how to keep the zeros

    Is there a way to preserve the zeros in a field when viewing in excel other than adding a ' at the front of the field?  I have a defined id in sql server as a varchar field, but what creating an xls document using cfspreadsheet excel interprets the numeric field and drop the zeros.  I can't have the "leading this field because it is imported in another system."

    This has been resolved.  I tested the two proposed solutions.  I tried to format the columns with spreadsheetformatcolumn as suggested by http://stackoverflow.com/questions/3081202/how-to-format-spreadsheet-c Columns-help-coldfusion , but which do not preserve the zeros in the column ID.  I then tried the solution with POI found here http://www.bennadel.com/projects/poi-utility.htm by Ben Nadel and who did keep the zeros.  Thanks for everyone's help and thanks to Ben for sharing his POI utility.

    -Julie

  • I downloaded 2015 CC wrong and only saw a box saying saying I can keep the old version. The Ill 2015 now says that it is a trial version for 30 days. How can I get my version of 2014 back that I paid for?

    I downloaded 2015 CC wrong and only saw a box saying saying I can keep the old version. The Ill 2015 now says that it is a trial version for 30 days. How can I get my version of 2014 back that I paid for?

    2 different problems:

    https://helpx.Adobe.com/Creative-Suite/KB/trial--1-launch.html

    Install an earlier version of any creative cloud application

  • How can I keep the zeros before a value?

    Hi guys

    I'm afraid that it will be the first in a series of question that I fall into my first complex program. So far, I've only done small scale, but it is heavier.

    The program will be a series of test for 10 circuits connected in 1 Panel. Each circuit have their own user serialnumber must enter in my program.

    Serial number have a first letter (A = year 2010, B = year 2011 and so forth). After that, there is a five-digit number.

    Example: A00001, A00002, A00003... etc.

    Because there are 10 serialnumbers I would like that the user inputs the first serial number: A00001. Then my program automatically increments the serial number of 1 for each circuit. Given that the letter is changed each year I put it as text to the left of the digital control, if the user only need to enter "00001".

    My program increment the serial number correctly and I can see the serial number for each circuit. The only problem is:

    What I want to see:

    User input: 00001

    SN1: 00001

    SN2: 00002

    ....

    SN10: 00010

    What I see:

    User input: 00001 (turns into 1)

    SN1: 1

    SN2: 2

    ....

    SN10: 10

    LabVIEW removes my zeros to the left of the value. Ways to change this? I tried to change the DBL to i32 or u32. I only managed to get the zeros «,»

    I could probably do any input string, but then I can't increment then user must enter 10 serialnumbers. Where I work, it is very important that the testcrew uses as few times as possible test.

    Thank you and best regards,

    Even

    Just give Format string like '04D %' in numerical order-> advanced editing mode.

    -Claude

  • I made my largest site and how can keep the same size for all other sites?

    I did the 2 larger site and how to keep the same size for all pages when I re - open the web browser?

    You can use an extension to set a page zoom and the size of the default font on the web pages.

  • Hi I'm looking to upgrade my iMac 2007 to a MacBook Pro that I can keep the iMac as an external hard drive is so how?

    WWhat should I do to keep all my photos and music files without having to complete my new mac book

    You can keep your iMac, but this isn't a very effective solution, if you just want to use it for storage. Sell and buy two external hard drives, one for extra storage and the other for a Time Machine backup drive that I speculate that you have not.

  • How to keep the zeros in a number in the excel output.

    Hi all

    I have a requirement to display numbers as text in the excel output. Ex: 001 should be displayed as 001 and not 1, as happens in excel.
    I know view 001 ' 001' works, but this is not acceptable.
    Also, I need to send a huge file (> 20MB) by bursting like an E-mail, but the mail is not received yet the program break ends in success. I tried the option compression as well, but to no avail. I know that this can be done by FTP, but I need to send it by e-mail.

    Thank you
    Rahul

    Maverick,

    See the admin:

    Administration and Developer's Guide
    Report Designer Guide

    Here:

    http://www.Oracle.com/technetwork/middleware/bi-Publisher/documentation/xmlpdocs-084437.html

    This will give you details on how to exit is divided into several files between burst. If I remember correctly, it is in the Administrator's guide.

    Kurz

    Published by: Kurzweil4 on December 6, 2010 09:11

    Published by: Kurzweil4 on December 6, 2010 09:11

  • I disabled MS Security Essentials that I use another antivirus - but I like to keep the firewall. How can I determine if it is effective?

    * Original title: Microsoft Firewall

    I read that Windows has a built-in firewall. I disabled MS Security Essentials that I use another antivirus - but I like to keep the firewall. How can I determine if it is effective? If this is not the case, how can I activate it?

    (Moved to programs)

    You cannot run the Windows Firewall and any other 3rd party firewall at the same time. By default, most if not all AV software (competent) devs teams to automatically disable the Windows Firewall when their own is installed to avoid unnecessary conflicts that would occur if both have been enabled at the same time.

    If you want to have the Windows Firewall, you will need to uninstall your antivirus (if it comes with a firewall) 3rd party. If this isn't the case, then you can keep the Windows Firewall is turned on, because it's good.

  • How can I keep the file rotation setting

    I can keep the rotation so my pdf is horizontal, the next time I open the file?

    With Adobe/Acrobat Reader you can only rotate the view to a file or page; It can not be registered and will not be kept.

    With Adobe Acrobat, you can turn permanently files or pages.

  • floating pictures in 11 one know how I can keep them in the workspace as elements 6

    floating pictures in Elements11, you know how I can keep the in the workspace as elements 6 really embarrassing when you look at Photoshop and picture blocks my computer desk or something simular or even blocks the opions of toolbar at the bottom, which seems both large all help in mmaking brought more or less above the 6 elements... (think I can just go back tho only 6)

    You can use the page layout button in the toolbar at the bottom to choose among several configurations. Once you have set your preferences as suggested by Barbara you can drag then onto the tabs, as appropriate, if they float independently.

  • How to test if the rest is a decimal number or an integer?

    Hi guys!

    I want to check whether or not my rest of two integers is a decimal number. Also, if it is a decimal number, I wana it allows to do a thing and if its an integer, I want her to do something else. How can I do?

    Help, please!

    Thanks in advance.

    Craster.D wrote:

    The task is to divide two numbers X and Y and a LED lights up if the result/rest is a decimal number. It can be higher or lower than 1, is not serious. If it is not a whole number, the LED should light.

    Great looks that you know exactly what you want to do, which seems to be the problem?  You will find the functions you need in the digital, boolean and comparison scheme.

  • Save for Web Action which keeps the size of the specific image

    I need to create an action recording for a 850 web x 655px.

    When testing my action for the first time, it shows in the Save as dialog box, the image has been reduced to this size as a percentage. If it works well.


    However, when you test the action on an image of different original report, it still reduces the percentage that had been recorded, rather than just to save the image to the 850 x 655, which gives me a different image size.

    Anyone know how I can keep the size of the image of 850 x 655 every time?

    Thank you

    NinjaPuss, this is what you need?

    /**
     * ai.jsx (c)MaratShagiev [email protected] 17.08.2016.
     */
    (function act_saveForWeb () {
      var d     = activeDocument;
      var dW    = d.width;
      var dH    = d.height;
      var wTmpl = 850;
      var hTmpl = 655;
      var wScale = ( wTmpl / dW ) * 100 + '';
      var hScale = ( hTmpl / dH) * 100 + '';
      {
        var actStr = '' +
          '/version 3' +
          '/name [ 10' +
          ' 73617665466f72576562' +
          ']' +
          '/isOpen 1' +
          '/actionCount 1' +
          '/action-1 {' +
          ' /name [ 10' +
          ' 73617665466f72576562' +
          ' ]' +
          ' /keyIndex 0' +
          ' /colorIndex 0' +
          ' /isOpen 1' +
          ' /eventCount 1' +
          ' /event-1 {' +
          ' /useRulersIn1stQuadrant 0' +
          ' /internalName (adobe_SaveForWeb)' +
          ' /localizedName [ 12' +
          ' 5361766520666f7220576562' +
          ' ]' +
          ' /isOpen 0' +
          ' /isOn 1' +
          ' /hasDialog 1' +
          ' /showDialog 1' +
          ' /parameterCount 16' +
          ' /parameter-1 {' +
          ' /key 1181578272' +
          ' /showInPalette -1' +
          ' /type (enumerated)' +
          ' /name [ 4' +
          ' 4a504547' +
          ' ]' +
          ' /value 1246774599' +
          ' }' +
          ' /parameter-2 {' +
          ' /key 1231975538' +
          ' /showInPalette -1' +
          ' /type (boolean)' +
          ' /value 0' +
          ' }' +
          ' /parameter-3 {' +
          ' /key 1366062201' +
          ' /showInPalette -1' +
          ' /type (integer)' +
          ' /value 60' +
          ' }' +
          ' /parameter-4 {' +
          ' /key 1332769901' +
          ' /showInPalette -1' +
          ' /type (boolean)' +
          ' /value 1' +
          ' }' +
          ' /parameter-5 {' +
          ' /key 1348563827' +
          ' /showInPalette -1' +
          ' /type (integer)' +
          ' /value 1' +
          ' }' +
          ' /parameter-6 {' +
          ' /key 1651275122' +
          ' /showInPalette -1' +
          ' /type (real)' +
          ' /value 0.0' +
          ' }' +
          ' /parameter-7 {' +
          ' /key 1299477536' +
          ' /showInPalette -1' +
          ' /type (boolean)' +
          ' /value 1' +
          ' }' +
          ' /parameter-8 {' +
          ' /key 1299477586' +
          ' /showInPalette -1' +
          ' /type (integer)' +
          ' /value 255' +
          ' }' +
          ' /parameter-9 {' +
          ' /key 1299477575' +
          ' /showInPalette -1' +
          ' /type (integer)' +
          ' /value 255' +
          ' }' +
          ' /parameter-10 {' +
          ' /key 1299477570' +
          ' /showInPalette -1' +
          ' /type (integer)' +
          ' /value 255' +
          ' }' +
          ' /parameter-11 {' +
          ' /key 1213424492' +
          ' /showInPalette -1' +
          ' /type (unit real)' +
          ' /value ' + wScale +
          ' /unit 592474723' +
          ' }' +
          ' /parameter-12 {' +
          ' /key 1448305516' +
          ' /showInPalette -1' +
          ' /type (unit real)' +
          ' /value ' + hScale +
          ' /unit 592474723' +
          ' }' +
          ' /parameter-13 {' +
          ' /key 1097757761' +
          ' /showInPalette -1' +
          ' /type (ustring)' +
          ' /value [ 13' +
          ' 417274204f7074696d697a6564' +
          ' ]' +
          ' }' +
          ' /parameter-14 {' +
          ' /key 1131180097' +
          ' /showInPalette -1' +
          ' /type (boolean)' +
          ' /value 1' +
          ' }' +
          ' /parameter-15 {' +
          ' /key 1399608180' +
          ' /showInPalette 0' +
          ' /type (raw)' +
          ' /value < 1574' +
          ' 0000000300000001000000000000000700000001000000000001000000000000' +
          ' 000001010000003c000000010000006400000000000000000000000000000002' +
          ' 00000000ffffffff0000000004ffffffff00000000ffffffff00000000ffffff' +
          ' ff00000000ffffffff0000000000000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000ff000000ff000000ff000000ff0000' +
          ' 00ff000000ff000000ff000000ff000000000000000000000000000001a80000' +
          ' 00100000000100000000000e54617267657453657474696e67730000000a0000' +
          ' 00004d7474434f626a630000000100000000000a4e6174697665517561640000' +
          ' 000300000000426c20206c6f6e67000000ff0000000047726e206c6f6e670000' +
          ' 00ff00000000526420206c6f6e67000000ff000000004f70746d626f6f6c0100' +
          ' 000000516c74796c6f6e670000003c0000000b6164644d65746164617461626f' +
          ' 6f6c010000000a626c7572416d6f756e74646f75620000000000000000000000' +
          ' 0f656d62656449434350726f66696c65626f6f6c000000000a66696c65466f72' +
          ' 6d6174656e756d0000000a46696c65466f726d6174000000004a504547000000' +
          ' 0c6e6f4d61747465436f6c6f72626f6f6c000000000b70726f67726573736976' +
          ' 65626f6f6c000000000c7a6f6e65645175616c6974794f626a63000000010000' +
          ' 000000095a6f6e6564496e666f00000004000000096368616e6e656c49446c6f' +
          ' 6e67ffffffff0000000d656d70686173697a6554657874626f6f6c0000000010' +
          ' 656d70686173697a65566563746f7273626f6f6c0000000005666c6f6f726c6f' +
          ' 6e6700000000' +
          ' >' +
          ' /size 1574' +
          ' }' +
          ' /parameter-16 {' +
          ' /key 1231953952' +
          ' /showInPalette -1' +
          ' /type (ustring)' +
          ' /value [ 28' +
          ' 433a5c55736572735c6d2e736861676965765c4465736b746f705c40' +
          ' ]' +
          ' }' +
          ' }' +
          '}'
      }
      var f = new File ('~/ScriptAction.aia');
      f.open ('w');
      f.write (actStr);
      f.close ();
      app.loadAction (f);
      f.remove ();
      app.doScript ("saveForWeb", "saveForWeb", false); // action name, set name
      app.unloadAction ("saveForWeb", ""); // set name
    } ());
    
  • Previously, you could use the mp4 files. Now when any mp4 file is a project unless it is a new project file only shows audio when you drag a package but you can see the preview of the video. WTF is underway.

    have not edited using first pro in a while. I recently had a new intro for a video made and had everything to see how it looks in a project that I just changed before and still work to do on. Not knowing anything is bad I import the mp4 in the file project, and note that it looks like this 77264721af38ccf90e95cad20b71abe2.png this means that you can import the audio in the timeline panel and yet I can see the video right there and when I open it up to an extract the file I can still see the video. After that I noticed this, I learned that other files mp4 which worked perfectly in the past now had this problem as well. I don't know what is happening on all I want to know how I can fix that I need this job that I use all the time a lot of files is in mp4.

    Found the problem be! It seems somehow that I have disabled the video portion of the timeline where it says V1. After allowing everything worked perfectly, I feel really stupid, but if anyone has this problem in the future, now, you know what to do

  • When my subscription expires, do to keep the software?

    I wonder if you can keep the software if your subscription expires. I understand that I would be ineligible for upgrades, but can we get keep the current version of their cloud creative software?

    N ° is a strict subscription - it works as long as you pay and then either.

    Mylenium

Maybe you are looking for