Data formatting problems

Hi all

I have some problems formatting in a query.

For example, if there is a single column with dats as follows:

col_ test
0
5
10
10.55123
10.678
(Note: they are all percentage values)

The data should look like this

col_ test
0.00
5.00
10 h 00
10.55
10.67

(Note: 2 decimal places, not rounded)


I wrote a query as below

Select to_char (trunc (test_col, 2), "0.99") test

I had the following data:

0.00
5.00
#####
#####
#####

Then I changed the query like this:


Select to_char (trunc (test_col, 2), "00.99'") test

The data I got was
00 h 00
05.00
10 h 00
10.55
10.67

But in this case it comes from the first two lines.
They must be fair
0.00
5.00

Is it possible that I can write a query so that the data will look like exactly as below:
0.00
5.00
10 h 00
10.55
10.67

It would be great if someone could help me.

Thank you
Verdier

Welcome to the forum.

You were very close:

SQL> -- generating sample data:
SQL> with t as (
  2  select 0  nbr from dual union
  3  select 5 from dual union
  4  select 10 from dual union
  5  select 10.55123 from dual union
  6  select 10.678 from dual
  7  )
  8  --
  9  -- actual query:
 10  --
 11  select to_char(trunc(nbr, 2), '90.99')
 12  from   t;

TO_CHA
------
  0.00
  5.00
 10.00
 10.55
 10.67

Tags: Database

Similar Questions

  • Date Format problem

    Hi all

    We spend date format '2015-05-26' of soapui for check-in, so it's inclusion in the database successfully.

    "But for the check-in validation Post filter service we copy the same date format from custom metadata to each other using Update Sql. we receive below IE error ' [' ORA-01843: not one month valid '.]

    Under sql queries work well for me. I've updated one of the rows in the table to approve revisions using sql developer, and it worked fine.

    UPDATE SET dcreatedate = TO_TIMESTAMP('15-MAY-2013 11:00:00:00','DD-MON-YYYY HH24:MI:SS:FF') WHERE did = 89 revisions;

    OR

    Setting a DAY of revision SET dcreatedate = systimestamp WHERE did = 89;

    You use java filter to update the query? Resource query you use?

  • SQL Date format problem

    Hello

    I try to place a conditional value in my SQL and extract is as follows:

    Select
    decode (TO_DATE (December 3, 2010 7:17 ',' DD/MM/YYYY HH24 '), null,)
    decode (TO_DATE (December 3, 2010 5:47 ',' MM/DD/YYYY HH24 '), null, ", TO_DATE (December 3, 2010 5:47 '," MM/DD/YYYY HH24 ' ")).
    decode (TO_DATE (December 3, 2010 5:47 ',' MM/DD/YYYY HH24 '), null, TO_DATE (December 3, 2010 7:17 ', "MM/DD/YYYY HH24 '"),)
    decode (sign (TO_DATE('12/3/2010 7:17', 'MM/DD/YYYY HH24:MI')-TO_DATE('12/3/2010 5:47', 'MM/DD/YYYY HH24:MI')), 1, TO_DATE (December 3, 2010 5:47 ',' MM/DD/YYYY HH24 '), TO_DATE (December 3, 2010 7:17 ',' MM/DD/YYYY HH24 '))
    ()) as a supplier
    of the double

    The dates above are just an example. It only gives me date rather than the date part time itself.

    If I NLS_DATE_FORMAT before this SQL it works planned. Is it possible without changing the format of the session I can achieve this?

    In addition, in MS excel we function IsError() we even in Oracle?

    Read http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/overview.htm#sthref247
    An example: http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:4630926692712

    Concerning

    Etbin

  • data formatting problem

    Hi all

    I'm providing dummy data and expected results. Help, please.

    with t as (SELECT '1 January 2009' ODATE, 20 QTY FROM DUAL)

    SELECT JANUARY 22, 2011 UNION ', 35 OF THE DOUBLE

    UNION SELECT ' 3 OCTOBER 2010', 80 OF THE DOUBLE

    SELECT DECEMBER 12, 2011 UNION ', 50 OF THE DOUBLE

    UNION SELECT 28 NOVEMBER 2013 ', 25 OF THE DOUBLE

    UNION SELECT 9 DECEMBER 2012 ", 30 OF THE DOUBLE

    UNION SELECT JANUARY 30, 2013 ', 70 DOUBLE)

    Select * from t;

    Output should be:

    KAI

    QTY.

    JANUARY

    20

    35

    70

    OCTOBER

    80

    NOVEMBER

    25

    DECEMBER

    50

    30

    It is a reporting requirement if I go in the client side. So, for example, if you use SQL Plus, you can use the BREAK command like this.

    SQL > break on Kai
    SQL >
    SQL > with t as
    () 2
    3 select to_date ('1st January 2009', ' mon-dd-yyyy "") odate, Qty 20 double
    4 union select to_date (January 22, 2011 ',' mon-dd-yyyy ""), 35 doubles
    5 union select to_date (October 3, 2010 ',' mon-dd-yyyy ""), the double 80
    6 union select to_date (12-dec-2011', ' mon-dd-yyyy ""), the double 50
    7 union select to_date (28 November 2013 ',' mon-dd-yyyy ""), 25 of the double
    8 union select to_date ('09-dec-2012', ' mon-dd-yyyy ""), 30 double
    9 union select to_date (January 30, 2013 ',' mon-dd-yyyy ""), 70 double
    10)
    11. Select shut
    12, Qty
    13 of)
    14 select to_char (odate, 'fmMONTH') Letter
    15, part of odate_num (month of Kai)
    16, Qty.
    17 t
    18         )
    order 19
    20 by odate_num
    21.

    KAI QTY.
    --------- ----------
    JANUARY 70
    35
    20
    OCTOBER 80
    NOVEMBER 25
    DECEMBER 30
    50

    7 selected lines.

    But if you want a SQL solution you can try like this.

    SQL > clear cut
    breaks erased

    SQL > with t as
    () 2
    3 select to_date ('1st January 2009', ' mon-dd-yyyy "") odate, Qty 20 double
    4 union select to_date (January 22, 2011 ',' mon-dd-yyyy ""), 35 doubles
    5 union select to_date (October 3, 2010 ',' mon-dd-yyyy ""), the double 80
    6 union select to_date (12-dec-2011', ' mon-dd-yyyy ""), the double 50
    7 union select to_date (28 November 2013 ',' mon-dd-yyyy ""), 25 of the double
    8 union select to_date ('09-dec-2012', ' mon-dd-yyyy ""), 30 double
    9 union select to_date (January 30, 2013 ',' mon-dd-yyyy ""), 70 double
    10)
    11. Select decodes (NWR, 1, Kai) Letter
    12, Qty
    13 of)
    14 select to_char (odate, 'fmMONTH') Letter
    15, row_number() over NWR (partition by excerpt (letter months) stopped by excerpt (months of letter))
    16, Qty.
    17 t
    18         )
    19.

    KAI QTY.
    --------- ----------
    JANUARY 70
    35
    20
    OCTOBER 80
    NOVEMBER 25
    DECEMBER 30
    50

    7 selected lines.

    SQL >

  • Problem with the conversion of getDate() to Date format?

    Hi guys,.

    I need to convert the date selected for DateField string format (for example: yyyy-mm-dd).

    I put the date format DateField as "mm-dd-yyyy '.»

    I tried to get the date of this DateField and tried to convert the format 'yyyy-mm-dd ".

    When I tried, I had a bad outing.

    For example, when I selected 12 months he returned as "00" the following coding.

    SimpleDateFormat dtFormat = new SimpleDateFormat("yyyy-mm-dd");
    Date dtToConvert = new Date(mydatefield.getDate());
    strRequired = dtFormat.formatLocal(dtToConvert); 
    

    Can someone explain what that is the bug with this code or any other way to get the output as my requirement?

    Thanks in advance,

    Stéphane

    Oops, sorry, code should have been...

    DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
    long dateLong = field.getDate();
    Date date = new Date(dateLong);
    String dateString =df.format(date);
    
  • problems by analyzing a date format string...

    Hi all, I'm having a hard time to convert a date into a string.

    I was using to_char but after much research, I thought that it would be better to use convert so I do:

    SELECT CONVERT (VARCHAR (8), 'November 19, 2012', 112) twice;

    Where the specifications for 112 is YYYYMMDD but I get the error "ORA-00936: lack of expression ', guess is cause Oracle do not know how to read the string to be converted.

    How can I convert a YYYYMMDD string format string of the form dd mmm yyy (as described above)?

    Thanks in advance,

    It seems that your search will lead you to a SQL Server thread. SQL Server uses arbitrary numbers to represent date formats. Oracle does not - the number 112 is irrelevant for Oracle.

    In Oracle, you convert a date to a string using the function TO_CHAR

    SELECT to_char( date '2012-11-19', 'YYYYMMDD' )
      FROM dual
    

    Of course, this assumes that you start with a date (like I do with my date literal). If you start with a string representing a date and you want to convert it to a string that represents the same date in a different format, you will need to use a TO_DATE and a TO_CHAR to convert the original string to a date and date on another string

    SELECT to_char( to_date( '19 Nov 2012', 'DD Mon YYYY' ), 'YYYYMMDD' )
      FROM dual
    

    Justin

  • Another problem with date formatting

    I want the date to appear at the Mmm - DD - but I get the date format full ODBC

    my query:
    < cfquery name = "monthlyChart" datasource = "2onboard" >
    SELECT distance, time, walkDate
    OF bockWalk
    WHERE the month (walkDate) = #month (Now ()) # AND year (walkDate) = #year (Now ()) #.
    < / cfquery >

    My cfchart:
    < cfchart format = "swf".
    style="/XML/dailyDistanceGraphs.xml".
    chartheight = '175 '.
    chartwidth = '575 '.
    ShowLegend = 'no '.
    showborder = 'yes '.
    show3d = 'no '.
    ForegroundColor = "000000".
    scaleFrom = '0 '.
    yaxistitle = "Mileage" >
    < cfchartseries type = 'bar '.
    Query = "monthlyChart."
    ValueColumn = 'distance '.
    PostesColonne = "walkDate".
    SeriesColor = "ff0000" >
    < / cfchartseries >
    < / cfchart >

    I tried formatting with an XML file
    Part of the XML file
    < xAxis >
    < isMultiline labelStyle = "false" orientation = "vertical" / >
    < style labelFormat = "Longdate" pattern = "Mmm - DD" / >
    < / xAxis >

    Quote:
    Posted by: jkgiven
    MikerRoo...
    Your solution stacks all of my entries in a column instead of one for each date, why/how to fix?
    Why the line in my work of xml?
    Can you explain or direct me to a source, the functioning of your lines? -J' I really need to learn XML, but it does not seem quite logical for me.

    Your entries are all in a single column because that is:
    (1) you have not set the pattern parseFormat matches what was returned by the database
    or
    (2) the granularity of the chart is set for monthly data and the data cover enough time. Change the dateTimeStyle to:

    did not work because (1) you need to set the mode to datetime axis
    and (2) the graphics engine is very stupid and need to be told exactly how to analyze the values returned in the query. It is the purpose of the tag.

    Finally, you need not learn the XML as such.
    The XML styles are covered, a little, in the docs from

    There is a practical tool, webcharts designer that you can use to generate the xml styles in:
    c:\CFusionMX7\charting\webcharts.bat

    The Webcharts user guide covers the styles available in more details. You can download that here:
    http://www.WebCharts3D.com/website/WebCharts50/download/index.jsp

  • slight problem with display of date format

    I have this query that produces a correct result, but not in the date format I need. Currently, it is the 'DD-MON-RR' display and I need it to appear in the format "MM/DD/YYYY". Can someone help me?

    Thank you
    Deanna


    SELECT TO_DATE(:P21_BEGIN_DATE,'MM/DD/YYYY') + (: P21_DAYS_OLD) FROM DUAL;

    Never use implicit date conversions:

    SELECT TO_CHAR(TO_DATE(:P21_BEGIN_DATE,'MM/DD/YYYY')+:P21_DAYS_OLD,'MM/DD/YYYY') FROM DUAL;
    

    SY.

  • How to advocate for regional change of short date format

    This is something relatively trivial but annoying all the same, but I don't know where to go to advocate for change.

    Have just updated for Sierra and one of the first things I notice is the addition of a point at the end of the month in short date format, i.e. 'September 19, 2016'.

    "In Australia, as in the United Kingdom, the standard must not use this period - it should be just'19 Sep 2016", and in the past, that's how it appeared in OSX for the Australia. Don't know why the change.

    This abbreviation is not replaceable by the user, so where can I go to provide appropriate feedback and I hope to have this problem on the track?

    A solution is to make my default language and region of the United Kingdom, but do not know if there is a price to pay for it.

    You can provide feedback to Apple asking them to change it:

    www.Apple.com/Feedback

  • How can I configure the cell data format

    How can I configure data format of cell numbers: for example, I want to capture 123456.78 and need to be 12A3456.78?

    I tried to put #A # #. # format option, but it didn't work a few time and it became A123456.78.

    I also tried on excel and it worked very well, but I like the numbers better. is there a solution to this problem?

    Thank you

    HEY Chi - Lun,

    I don't think that this is possible as many number format. You should be able to insert A in a text string using a formula, but this would happen in a second cell, not that the number has been entered.

    "Assuming all the"numbers require the same inserted letter after the second number, this should do the work."number" entered in column A; the formula in column B. In the table below, your value as an example is A6.

    = Left (A, 2) & "A" & RIGHT (A, LEN (A) - 2)

    Kind regards

    Barry

  • Cannot save the incorrect date format

    I keep trying to save my computer... tells me incorrect date format?

    I had the same problem and ended up going through the online chat.  I guess there is a problem with the site, but they managed to sign up to my computer via chat.  Hope that helps

  • Sort data in date format DD/MM/RRRR

    Hello

    I have to sort our data between two dates ex 01 01, 2016 to the 31/01/2016 for the list of transactions.

    Will I convert in JAN-16 format so that I can sort by where period_name like ' JAN-16'?

    If so how do I convert a date format of 01/01/2016 JAN-16?

    Thank you

    Hello

    Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

    Also post the exact results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

    As Chris and Tubby has said, all DATEs are stored in the same internal format, which has nothing to do with the format you use to view or format you use in conversion as TO_DATE functions.

    Oracle provides many functions and other features for the manipulation of DATEs, you seldom need to convert them to another format.  For example, we wanted to get a list of employees of the scott.emp sorted by month and by ename; in other words, December 1980 would come before April, 1981, as from habit, but the day of the month, hours minutes and seconds would all be ignored in sorting.  We can use the TRUNC function to do this:

    SELECT TO_CHAR (hiredate, 'Mon-YYYY') AS hiremonth

    ename

    hiredate

    FROM scott.emp

    ORDER BY TRUNC (hiredate, 'MONTH')

    ename

    ;

    Output:

    HIREMONTH ENAME HIREDATE

    ---------- ---------- -----------

    DEC-1980 SMITH December 17, 1980

    Feb-1981 ALLEN 20 February 1981

    Feb-1981 WARD 22 February 1981

    Apr-1981 JONES April 2, 1981

    May-1981 BLAKE may 1, 1981

    Jun-1981 CLARK June 9, 1981

    MARTIN 1981-Sep 28-Sep-1981

    Sep-1981 TURNER 08-Sep-1981

    Nov-1981 KING November 17, 1981

    DEC-1981 FORD December 3, 1981

    DEC-1981 JAMES December 3, 1981

    Jan-1982 MILLER January 23, 1982

    Apr-1987 SCOTT April 19, 1987

    May-1987 ADAMS 23 May 1987

    Notice how MARTIN comes before TURNER in the output (I marked these Redlines), even if MARTIN hiredate is 20 days later than TURNER.  This is because only the year and month are considered in the sorting.  Any DATE in the same month will get the same sort value.

  • date format limits in the workflow

    Hello

    I try to add a time limit to one per programming workflows, but I have problem with the date format

    How do I format this date? ¿It is a date or a string?

    < workflowengine:completeassignment

    "site ="pub_id"

    "ID ="assignment_id"

    [ACTION ="action_comment" "]

    [comment ="comment" "]

    "NeXTSTEP ="next_workflow_step_id"

    "varname ="assignment_name"

    ["date limit ="deadline""]

    [assignmentlist ="participant_object" "] / >

    Thank you

    Finally, the date must be a string with the date in milliseconds.

  • convert date format period

    Hi all

    Here are my existing query which I run another tool to extract data from oracle-

    Select * from transactionTbl

    WHERE

    DATE > = TO_DATE (' $(vAppStartDate)', "DD/MM/YYYY")

    AND DATE < = TO_DATE (' $(vAppEndDate)', "DD/MM/YYYY")

    variables-

    -vAppStartDate = 06/01/2014

    -vAppEndDate = 30/06/2015

    Rather than use the Date column in the WHERE condition, I want to use PeriodID of column existing in the same table, to make the query faster.

    The period column is in below format.

    PeriodID format-> 201294 //means 2012Q 4. So 9 means Q

    Since I'm on variables, the values are always to the date format, so my requirement is first change variable date from periods of format.

    I wrote the pseudo-code, because I of course know how to convert date format periodID. Q also means in the periodID 9.

    Select * from transactionTbl

    WHERE

    PeriodID > = period_function (TO_DATE (July 1, 14 ',' DD/MM/YYYY '), 'YYYYxx')

    AND PeriodID > = period_function (TO_DATE (July 1, 15 ',' DD/MM/YYYY '), 'YYYYxx')

    Please help me with the query.

    Thank you!

    Calling a user-defined function is likely to slow down your query.

    What's the problem with just using regular date formatting strings for example

    SQL > select to_char (to_date('15/09/2014','DD/MM/YYYY'), 'YYYY "9" Q') of double;
    TO_CHA
    ------
    201493

    1 selected line.

  • Bug - import drop of time - data format literals?

    SQL Developer 4.1 ai2

    If I put in place an import of data using INSERTs and specify a format string for a timestamp field that includes literals, these removed in the instructions for INSERTING generated resulting:

    Format: YYYY-MM-DD "T" HH24:MI:SS. " FF3 ""-07:00 " "

    Data_Import_Wizard_-_Step_4_of_5.png

    INSERT resulting:

    Oracle_SQL_Developer____var_folders_py_jrrk_5490y95w7816tzqbygm0092f2_T_Import-phys-reqs-by-user-time-tsv_1_sql.png

    Get the recitals:

    SQL error: ORA-01821: date format not recognized

    Set the format:

    Oracle_SQL_Developer____var_folders_py_jrrk_5490y95w7816tzqbygm0092f2_T_Import-phys-reqs-by-user-time-tsv_1_sql.png

    Works as it should:

    1 row inserted.

    (I know I'm butchering the timestamp/zone - that is by the by ;-)) )

    We were stripping the quotes of the mask of date format for a reason-this problem has been fixed

Maybe you are looking for

  • Fees and the QFE files install on Satellite A660

    A660. I plan to do a new installation if winows pro 7 64 on my machine of retail disk. In the folder driovers of toshiba, I see some files as files QFE-do I need? or is windows update install? Also is there a way tp preserve the thing of recovery tos

  • BJMKFR32. DLL IS NOT INSTALLED

    Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: You have problems with programs Error messages Recent changes to your computer What you have already tried to solve the problem

  • QoS LAN - how to say switchport reassign CoS value to mixt?

    Hi all There is an order issued on the switchport which tells a Cisco IP Phone trust the CoS of a station connected to the access of the phone port said, but to change the tag to a CoS value of your choice. Example: MSL qos trust cos switchport prior

  • No sound in games and online TV.

    For some reason, I have no sound on any games or online TV etc.  The President seems to be on and not muted.  I'm not very good with computers, can someone help me please? OT: Good question

  • Creating forms

    I have DC of Acrobat Reader.  I am able to create forms that can be filled either on my website or otherwise?  If not, what type of Acrobat do I need to create my own forms to be completed by the beneficiary of the form?  Also must the beneficiary ha